layout: doc_page

KLL Sketch Accuracy and Size

The accuracy of the KLL quantile sketch is a function of the configured K, which also affects the overall size of the sketch (default K = 200).

The accuracy of quantiles sketches is specified and measured with respect to the rank only, not the quantiles.

The KLL Sketch has absolute error. For example, a specified rank accuracy of 1% at the median (rank = 0.50) means that the true quantile (if you could extract it from the set) should be between getQuantile(0.49) and getQuantile(0.51). This same 1% error applied at a rank of 0.95 means that the true quantile should be between getQuantile(0.94) and getQuantile(0.96). In other words, the error is a fixed +/- epsilon for the entire range of ranks.

The approximate rank error values listed in the second row of the header in the table below can be computed using the function KLLSketch.getNormalizedRankError(int k, false). The third row shows the double-sided error that applies to a portion of the distribution such as an element of PMF (bar in a histogram) that is a subject to rank error on both sides. It can be computed using the function KLLSketch.getNormalizedRankError(int k, true).

KllFloatsSketch (Java) or kll_sketch<float> (C++) serialized size in bytes from K or rank error % vs. N.

NK=25K=50K=100K=200K=400K=800K=1600
single-sided error10.04%5.12%2.61%1.33%0.68%0.35%0.18%
double-sided error11.74%6.11%3.18%1.65%0.86%0.45%0.23%
08888888
140404040404040
244444444444444
452525252525252
868686868686868
16100100100100100100100
32120164164164164164164
64188196292292292292292
128220336352548548548548
2562683966326641,0601,0601,060
5122885247441,2241,2882,0842,084
1,0243565689881,4362,4042,5364,132
2,0483925561,0361,9122,8124,7685,032
4,0964286281,0121,9963,7405,5809,492
8,1924486561,0042,1563,8447,44011,116
16,3844967081,2242,1484,1047,64814,820
32,7685287401,2602,3444,3848,23615,228
65,5365567641,2922,1204,6648,77216,236
131,0726128001,3042,4364,7409,28017,592
262,1446328441,3522,4644,7448,64418,268
524,2886808801,3922,5124,7809,34418,724
1,048,5767209161,4362,5484,7729,56018,932
2,097,1527449481,4602,5844,8609,58419,008
4,194,3047801,0001,5002,6164,9289,57218,892
8,388,6088121,0321,5402,6404,9609,65619,036
16,777,2168521,0521,5842,6805,0009,70819,204
33,554,4328921,1081,6202,7245,0329,72818,620
67,108,8649281,1241,6482,7605,0409,76419,276
134,217,7289361,1681,6882,7805,1009,80819,304
268,435,4569641,2001,6962,8325,1369,84819,336
536,870,9129921,2321,7522,8685,1769,87619,396
1,073,741,8241,0201,2841,7842,8885,2129,92419,404
2,147,483,6481,0801,3081,8242,9245,2449,95619,448
4,294,967,2961,1081,3561,8642,9765,2649,98019,488
8,589,934,5921,1481,3841,8882,9925,31210,03219,540
17,179,869,1841,1881,4321,9363,0405,34410,05219,576

KllDoublesSketch (Java) or kll_sketch<double> (C++) serialized size in bytes from K or rank error % vs. N.

NK=25K=50K=100K=200K=400K=800k=1600
single-sided error10.04%5.12%2.61%1.33%0.68%0.35%0.18%
double-sided error11.74%6.11%3.18%1.65%0.86%0.45%0.23%
08888888
156565656565656
264646464646464
480808080808080
8112112112112112112112
16176176176176176176176
32212304304304304304304
64348364560560560560560
1284086446761,0721,0721,0721,072
2565007601,2361,3002,0962,0962,096
5125361,0121,4562,4202,5484,1444,144
1,0246681,0961,9402,8404,7805,0448,240
2,0487361,0682,0323,7885,5929,50810,036
4,0968041,2081,9803,9527,44411,12818,956
8,1928401,2601,9604,2687,64814,84422,200
16,3849321,3602,3964,2488,16415,25629,604
32,7689921,4202,4644,6368,72016,42830,416
65,5361,0441,4642,5244,1849,27617,49632,428
131,0721,1521,5322,5444,8129,42418,50835,136
262,1441,1881,6162,6364,8649,42817,23236,484
524,2881,2801,6842,7124,9569,49618,62837,392
1,048,5761,3561,7522,7965,0249,47619,05637,804
2,097,1521,4001,8122,8405,0929,64819,10037,952
4,194,3041,4681,9122,9165,1529,78019,07237,716
8,388,6081,5281,9722,9925,1969,84019,23638,000
16,777,2161,6042,0083,0765,2729,91619,33638,332
33,554,4321,6802,1163,1445,3569,97619,37237,160
67,108,8641,7482,1443,1965,4249,98819,44038,468
134,217,7281,7642,2283,2725,46010,10419,52438,520
268,435,4561,8162,2883,2845,56010,17219,60038,580
536,870,9121,8682,3483,3925,62810,24819,65238,696
1,073,741,8241,9202,4483,4525,66410,31619,74438,708
2,147,483,6482,0362,4923,5285,73210,37619,80438,792
4,294,967,2962,0882,5843,6045,83210,41219,84838,868
8,589,934,5922,1642,6363,6485,86010,50419,94838,968
17,179,869,1842,2402,7283,7405,95210,56419,98439,036