datasketches 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/LICENSE +310 -0
- data/NOTICE +11 -0
- data/README.md +126 -0
- data/ext/datasketches/cpc_wrapper.cpp +50 -0
- data/ext/datasketches/ext.cpp +12 -0
- data/ext/datasketches/extconf.rb +11 -0
- data/ext/datasketches/hll_wrapper.cpp +69 -0
- data/lib/datasketches.rb +9 -0
- data/lib/datasketches/version.rb +3 -0
- data/vendor/datasketches-cpp/CMakeLists.txt +126 -0
- data/vendor/datasketches-cpp/LICENSE +311 -0
- data/vendor/datasketches-cpp/MANIFEST.in +19 -0
- data/vendor/datasketches-cpp/NOTICE +11 -0
- data/vendor/datasketches-cpp/README.md +42 -0
- data/vendor/datasketches-cpp/common/CMakeLists.txt +45 -0
- data/vendor/datasketches-cpp/common/include/MurmurHash3.h +173 -0
- data/vendor/datasketches-cpp/common/include/binomial_bounds.hpp +458 -0
- data/vendor/datasketches-cpp/common/include/bounds_binomial_proportions.hpp +291 -0
- data/vendor/datasketches-cpp/common/include/ceiling_power_of_2.hpp +41 -0
- data/vendor/datasketches-cpp/common/include/common_defs.hpp +51 -0
- data/vendor/datasketches-cpp/common/include/conditional_back_inserter.hpp +68 -0
- data/vendor/datasketches-cpp/common/include/conditional_forward.hpp +70 -0
- data/vendor/datasketches-cpp/common/include/count_zeros.hpp +114 -0
- data/vendor/datasketches-cpp/common/include/inv_pow2_table.hpp +107 -0
- data/vendor/datasketches-cpp/common/include/memory_operations.hpp +57 -0
- data/vendor/datasketches-cpp/common/include/serde.hpp +196 -0
- data/vendor/datasketches-cpp/common/test/CMakeLists.txt +38 -0
- data/vendor/datasketches-cpp/common/test/catch.hpp +17618 -0
- data/vendor/datasketches-cpp/common/test/catch_runner.cpp +7 -0
- data/vendor/datasketches-cpp/common/test/test_allocator.cpp +31 -0
- data/vendor/datasketches-cpp/common/test/test_allocator.hpp +108 -0
- data/vendor/datasketches-cpp/common/test/test_runner.cpp +29 -0
- data/vendor/datasketches-cpp/common/test/test_type.hpp +137 -0
- data/vendor/datasketches-cpp/cpc/CMakeLists.txt +74 -0
- data/vendor/datasketches-cpp/cpc/include/compression_data.hpp +6022 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_common.hpp +62 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor.hpp +147 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +742 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_confidence.hpp +167 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch.hpp +311 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +810 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_union.hpp +102 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +346 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_util.hpp +137 -0
- data/vendor/datasketches-cpp/cpc/include/icon_estimator.hpp +274 -0
- data/vendor/datasketches-cpp/cpc/include/kxp_byte_lookup.hpp +81 -0
- data/vendor/datasketches-cpp/cpc/include/u32_table.hpp +84 -0
- data/vendor/datasketches-cpp/cpc/include/u32_table_impl.hpp +266 -0
- data/vendor/datasketches-cpp/cpc/test/CMakeLists.txt +44 -0
- data/vendor/datasketches-cpp/cpc/test/compression_test.cpp +67 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_test.cpp +381 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_union_test.cpp +149 -0
- data/vendor/datasketches-cpp/fi/CMakeLists.txt +54 -0
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch.hpp +319 -0
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +484 -0
- data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map.hpp +114 -0
- data/vendor/datasketches-cpp/fi/include/reverse_purge_hash_map_impl.hpp +345 -0
- data/vendor/datasketches-cpp/fi/test/CMakeLists.txt +44 -0
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_custom_type_test.cpp +84 -0
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_test.cpp +360 -0
- data/vendor/datasketches-cpp/fi/test/items_sketch_string_from_java.sk +0 -0
- data/vendor/datasketches-cpp/fi/test/items_sketch_string_utf8_from_java.sk +0 -0
- data/vendor/datasketches-cpp/fi/test/longs_sketch_from_java.sk +0 -0
- data/vendor/datasketches-cpp/fi/test/reverse_purge_hash_map_test.cpp +47 -0
- data/vendor/datasketches-cpp/hll/CMakeLists.txt +92 -0
- data/vendor/datasketches-cpp/hll/include/AuxHashMap-internal.hpp +303 -0
- data/vendor/datasketches-cpp/hll/include/AuxHashMap.hpp +83 -0
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable-internal.hpp +811 -0
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable.hpp +40 -0
- data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +291 -0
- data/vendor/datasketches-cpp/hll/include/CouponHashSet.hpp +59 -0
- data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +417 -0
- data/vendor/datasketches-cpp/hll/include/CouponList.hpp +91 -0
- data/vendor/datasketches-cpp/hll/include/CubicInterpolation-internal.hpp +233 -0
- data/vendor/datasketches-cpp/hll/include/CubicInterpolation.hpp +43 -0
- data/vendor/datasketches-cpp/hll/include/HarmonicNumbers-internal.hpp +90 -0
- data/vendor/datasketches-cpp/hll/include/HarmonicNumbers.hpp +48 -0
- data/vendor/datasketches-cpp/hll/include/Hll4Array-internal.hpp +335 -0
- data/vendor/datasketches-cpp/hll/include/Hll4Array.hpp +69 -0
- data/vendor/datasketches-cpp/hll/include/Hll6Array-internal.hpp +124 -0
- data/vendor/datasketches-cpp/hll/include/Hll6Array.hpp +55 -0
- data/vendor/datasketches-cpp/hll/include/Hll8Array-internal.hpp +158 -0
- data/vendor/datasketches-cpp/hll/include/Hll8Array.hpp +56 -0
- data/vendor/datasketches-cpp/hll/include/HllArray-internal.hpp +706 -0
- data/vendor/datasketches-cpp/hll/include/HllArray.hpp +136 -0
- data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +462 -0
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl-internal.hpp +149 -0
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl.hpp +85 -0
- data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +170 -0
- data/vendor/datasketches-cpp/hll/include/HllUnion-internal.hpp +287 -0
- data/vendor/datasketches-cpp/hll/include/HllUtil.hpp +239 -0
- data/vendor/datasketches-cpp/hll/include/RelativeErrorTables-internal.hpp +112 -0
- data/vendor/datasketches-cpp/hll/include/RelativeErrorTables.hpp +46 -0
- data/vendor/datasketches-cpp/hll/include/coupon_iterator-internal.hpp +56 -0
- data/vendor/datasketches-cpp/hll/include/coupon_iterator.hpp +43 -0
- data/vendor/datasketches-cpp/hll/include/hll.hpp +669 -0
- data/vendor/datasketches-cpp/hll/include/hll.private.hpp +32 -0
- data/vendor/datasketches-cpp/hll/test/AuxHashMapTest.cpp +79 -0
- data/vendor/datasketches-cpp/hll/test/CMakeLists.txt +51 -0
- data/vendor/datasketches-cpp/hll/test/CouponHashSetTest.cpp +130 -0
- data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +181 -0
- data/vendor/datasketches-cpp/hll/test/CrossCountingTest.cpp +93 -0
- data/vendor/datasketches-cpp/hll/test/HllArrayTest.cpp +191 -0
- data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +389 -0
- data/vendor/datasketches-cpp/hll/test/HllUnionTest.cpp +313 -0
- data/vendor/datasketches-cpp/hll/test/IsomorphicTest.cpp +141 -0
- data/vendor/datasketches-cpp/hll/test/TablesTest.cpp +44 -0
- data/vendor/datasketches-cpp/hll/test/ToFromByteArrayTest.cpp +168 -0
- data/vendor/datasketches-cpp/hll/test/array6_from_java.sk +0 -0
- data/vendor/datasketches-cpp/hll/test/compact_array4_from_java.sk +0 -0
- data/vendor/datasketches-cpp/hll/test/compact_set_from_java.sk +0 -0
- data/vendor/datasketches-cpp/hll/test/list_from_java.sk +0 -0
- data/vendor/datasketches-cpp/hll/test/updatable_array4_from_java.sk +0 -0
- data/vendor/datasketches-cpp/hll/test/updatable_set_from_java.sk +0 -0
- data/vendor/datasketches-cpp/kll/CMakeLists.txt +58 -0
- data/vendor/datasketches-cpp/kll/include/kll_helper.hpp +150 -0
- data/vendor/datasketches-cpp/kll/include/kll_helper_impl.hpp +319 -0
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator.hpp +67 -0
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator_impl.hpp +169 -0
- data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +559 -0
- data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +1131 -0
- data/vendor/datasketches-cpp/kll/test/CMakeLists.txt +44 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_custom_type_test.cpp +154 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_float_one_item_v1.sk +0 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_from_java.sk +0 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_test.cpp +685 -0
- data/vendor/datasketches-cpp/kll/test/kll_sketch_validation.cpp +229 -0
- data/vendor/datasketches-cpp/pyproject.toml +17 -0
- data/vendor/datasketches-cpp/python/CMakeLists.txt +61 -0
- data/vendor/datasketches-cpp/python/README.md +78 -0
- data/vendor/datasketches-cpp/python/jupyter/CPCSketch.ipynb +345 -0
- data/vendor/datasketches-cpp/python/jupyter/FrequentItemsSketch.ipynb +354 -0
- data/vendor/datasketches-cpp/python/jupyter/HLLSketch.ipynb +346 -0
- data/vendor/datasketches-cpp/python/jupyter/KLLSketch.ipynb +463 -0
- data/vendor/datasketches-cpp/python/jupyter/ThetaSketchNotebook.ipynb +396 -0
- data/vendor/datasketches-cpp/python/src/__init__.py +2 -0
- data/vendor/datasketches-cpp/python/src/cpc_wrapper.cpp +90 -0
- data/vendor/datasketches-cpp/python/src/datasketches.cpp +40 -0
- data/vendor/datasketches-cpp/python/src/fi_wrapper.cpp +123 -0
- data/vendor/datasketches-cpp/python/src/hll_wrapper.cpp +136 -0
- data/vendor/datasketches-cpp/python/src/kll_wrapper.cpp +209 -0
- data/vendor/datasketches-cpp/python/src/theta_wrapper.cpp +162 -0
- data/vendor/datasketches-cpp/python/src/vector_of_kll.cpp +488 -0
- data/vendor/datasketches-cpp/python/src/vo_wrapper.cpp +140 -0
- data/vendor/datasketches-cpp/python/tests/__init__.py +0 -0
- data/vendor/datasketches-cpp/python/tests/cpc_test.py +64 -0
- data/vendor/datasketches-cpp/python/tests/fi_test.py +110 -0
- data/vendor/datasketches-cpp/python/tests/hll_test.py +131 -0
- data/vendor/datasketches-cpp/python/tests/kll_test.py +119 -0
- data/vendor/datasketches-cpp/python/tests/theta_test.py +121 -0
- data/vendor/datasketches-cpp/python/tests/vector_of_kll_test.py +148 -0
- data/vendor/datasketches-cpp/python/tests/vo_test.py +101 -0
- data/vendor/datasketches-cpp/sampling/CMakeLists.txt +48 -0
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch.hpp +392 -0
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +1752 -0
- data/vendor/datasketches-cpp/sampling/include/var_opt_union.hpp +239 -0
- data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +645 -0
- data/vendor/datasketches-cpp/sampling/test/CMakeLists.txt +43 -0
- data/vendor/datasketches-cpp/sampling/test/binaries_from_java.txt +67 -0
- data/vendor/datasketches-cpp/sampling/test/var_opt_sketch_test.cpp +509 -0
- data/vendor/datasketches-cpp/sampling/test/var_opt_union_test.cpp +358 -0
- data/vendor/datasketches-cpp/sampling/test/varopt_sketch_long_sampling.sk +0 -0
- data/vendor/datasketches-cpp/sampling/test/varopt_sketch_string_exact.sk +0 -0
- data/vendor/datasketches-cpp/sampling/test/varopt_union_double_sampling.sk +0 -0
- data/vendor/datasketches-cpp/setup.py +94 -0
- data/vendor/datasketches-cpp/theta/CMakeLists.txt +57 -0
- data/vendor/datasketches-cpp/theta/include/theta_a_not_b.hpp +73 -0
- data/vendor/datasketches-cpp/theta/include/theta_a_not_b_impl.hpp +83 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection.hpp +88 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection_impl.hpp +130 -0
- data/vendor/datasketches-cpp/theta/include/theta_sketch.hpp +533 -0
- data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +939 -0
- data/vendor/datasketches-cpp/theta/include/theta_union.hpp +122 -0
- data/vendor/datasketches-cpp/theta/include/theta_union_impl.hpp +109 -0
- data/vendor/datasketches-cpp/theta/test/CMakeLists.txt +45 -0
- data/vendor/datasketches-cpp/theta/test/theta_a_not_b_test.cpp +244 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_single_item_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_intersection_test.cpp +218 -0
- data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +438 -0
- data/vendor/datasketches-cpp/theta/test/theta_union_test.cpp +97 -0
- data/vendor/datasketches-cpp/theta/test/theta_update_empty_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_update_estimation_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/CMakeLists.txt +104 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_a_not_b.hpp +52 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_a_not_b_impl.hpp +32 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_intersection.hpp +52 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_intersection_impl.hpp +31 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch.hpp +179 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch_impl.hpp +238 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union.hpp +81 -0
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union_impl.hpp +43 -0
- data/vendor/datasketches-cpp/tuple/include/bounds_on_ratios_in_sampled_sets.hpp +135 -0
- data/vendor/datasketches-cpp/tuple/include/bounds_on_ratios_in_theta_sketched_sets.hpp +135 -0
- data/vendor/datasketches-cpp/tuple/include/jaccard_similarity.hpp +172 -0
- data/vendor/datasketches-cpp/tuple/include/theta_a_not_b_experimental.hpp +53 -0
- data/vendor/datasketches-cpp/tuple/include/theta_a_not_b_experimental_impl.hpp +33 -0
- data/vendor/datasketches-cpp/tuple/include/theta_comparators.hpp +48 -0
- data/vendor/datasketches-cpp/tuple/include/theta_constants.hpp +34 -0
- data/vendor/datasketches-cpp/tuple/include/theta_helpers.hpp +54 -0
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_base.hpp +59 -0
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_base_impl.hpp +121 -0
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_experimental.hpp +78 -0
- data/vendor/datasketches-cpp/tuple/include/theta_intersection_experimental_impl.hpp +43 -0
- data/vendor/datasketches-cpp/tuple/include/theta_set_difference_base.hpp +54 -0
- data/vendor/datasketches-cpp/tuple/include/theta_set_difference_base_impl.hpp +80 -0
- data/vendor/datasketches-cpp/tuple/include/theta_sketch_experimental.hpp +393 -0
- data/vendor/datasketches-cpp/tuple/include/theta_sketch_experimental_impl.hpp +481 -0
- data/vendor/datasketches-cpp/tuple/include/theta_union_base.hpp +60 -0
- data/vendor/datasketches-cpp/tuple/include/theta_union_base_impl.hpp +84 -0
- data/vendor/datasketches-cpp/tuple/include/theta_union_experimental.hpp +88 -0
- data/vendor/datasketches-cpp/tuple/include/theta_union_experimental_impl.hpp +47 -0
- data/vendor/datasketches-cpp/tuple/include/theta_update_sketch_base.hpp +259 -0
- data/vendor/datasketches-cpp/tuple/include/theta_update_sketch_base_impl.hpp +389 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_a_not_b.hpp +57 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_a_not_b_impl.hpp +33 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_intersection.hpp +104 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_intersection_impl.hpp +43 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +496 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +587 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_union.hpp +109 -0
- data/vendor/datasketches-cpp/tuple/include/tuple_union_impl.hpp +47 -0
- data/vendor/datasketches-cpp/tuple/test/CMakeLists.txt +53 -0
- data/vendor/datasketches-cpp/tuple/test/aod_1_compact_empty_from_java.sk +1 -0
- data/vendor/datasketches-cpp/tuple/test/aod_1_compact_estimation_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/aod_1_compact_non_empty_no_entries_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/aod_2_compact_exact_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/aod_3_compact_empty_from_java.sk +1 -0
- data/vendor/datasketches-cpp/tuple/test/array_of_doubles_sketch_test.cpp +298 -0
- data/vendor/datasketches-cpp/tuple/test/theta_a_not_b_experimental_test.cpp +250 -0
- data/vendor/datasketches-cpp/tuple/test/theta_compact_empty_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/theta_compact_estimation_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/theta_compact_single_item_from_java.sk +0 -0
- data/vendor/datasketches-cpp/tuple/test/theta_intersection_experimental_test.cpp +224 -0
- data/vendor/datasketches-cpp/tuple/test/theta_jaccard_similarity_test.cpp +144 -0
- data/vendor/datasketches-cpp/tuple/test/theta_sketch_experimental_test.cpp +247 -0
- data/vendor/datasketches-cpp/tuple/test/theta_union_experimental_test.cpp +44 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_a_not_b_test.cpp +289 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_intersection_test.cpp +235 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_jaccard_similarity_test.cpp +98 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_allocation_test.cpp +102 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_test.cpp +249 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +187 -0
- metadata +302 -0
@@ -0,0 +1,463 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "markdown",
|
5
|
+
"metadata": {},
|
6
|
+
"source": [
|
7
|
+
"## KLL Sketch Examples"
|
8
|
+
]
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"cell_type": "markdown",
|
12
|
+
"metadata": {},
|
13
|
+
"source": [
|
14
|
+
"### Basic Sketch Usage"
|
15
|
+
]
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"cell_type": "code",
|
19
|
+
"execution_count": 1,
|
20
|
+
"metadata": {},
|
21
|
+
"outputs": [],
|
22
|
+
"source": [
|
23
|
+
"from datasketches import kll_floats_sketch, kll_ints_sketch"
|
24
|
+
]
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"cell_type": "markdown",
|
28
|
+
"metadata": {},
|
29
|
+
"source": [
|
30
|
+
"Options are a `kll_floats_sketch` or `kll_ints_sketch`. We'll use the former so we can draw samples from a Gaussian distribution. We start by creating a sketch with $k=200$, which gives a normalized rank error of about 1.65%, and feeding in 1 million points."
|
31
|
+
]
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"cell_type": "code",
|
35
|
+
"execution_count": 2,
|
36
|
+
"metadata": {},
|
37
|
+
"outputs": [],
|
38
|
+
"source": [
|
39
|
+
"n = 1000000\n",
|
40
|
+
"kll = kll_floats_sketch(200)\n",
|
41
|
+
"from numpy.random import randn\n",
|
42
|
+
"for i in range(0, n):\n",
|
43
|
+
" kll.update(randn()) "
|
44
|
+
]
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"cell_type": "markdown",
|
48
|
+
"metadata": {},
|
49
|
+
"source": [
|
50
|
+
"Since the data is distributed as $\\cal{N}(0,1)$, 0.0 should be near the median rank (0.5)"
|
51
|
+
]
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"cell_type": "code",
|
55
|
+
"execution_count": 3,
|
56
|
+
"metadata": {},
|
57
|
+
"outputs": [
|
58
|
+
{
|
59
|
+
"data": {
|
60
|
+
"text/plain": [
|
61
|
+
"0.497608"
|
62
|
+
]
|
63
|
+
},
|
64
|
+
"execution_count": 3,
|
65
|
+
"metadata": {},
|
66
|
+
"output_type": "execute_result"
|
67
|
+
}
|
68
|
+
],
|
69
|
+
"source": [
|
70
|
+
"kll.get_rank(0.0)"
|
71
|
+
]
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"cell_type": "markdown",
|
75
|
+
"metadata": {},
|
76
|
+
"source": [
|
77
|
+
"And the median should also be near 0.0"
|
78
|
+
]
|
79
|
+
},
|
80
|
+
{
|
81
|
+
"cell_type": "code",
|
82
|
+
"execution_count": 4,
|
83
|
+
"metadata": {},
|
84
|
+
"outputs": [
|
85
|
+
{
|
86
|
+
"data": {
|
87
|
+
"text/plain": [
|
88
|
+
"0.003108405973762274"
|
89
|
+
]
|
90
|
+
},
|
91
|
+
"execution_count": 4,
|
92
|
+
"metadata": {},
|
93
|
+
"output_type": "execute_result"
|
94
|
+
}
|
95
|
+
],
|
96
|
+
"source": [
|
97
|
+
"kll.get_quantile(0.5)"
|
98
|
+
]
|
99
|
+
},
|
100
|
+
{
|
101
|
+
"cell_type": "markdown",
|
102
|
+
"metadata": {},
|
103
|
+
"source": [
|
104
|
+
"We track the min and max values as well. They are stored separately from the quantile data so we can always determine the full _empirical_ data range. In this case they should be very roughly symmetric around 0.0. We can query these values explicitly, or implicitly by asking for the values at ranks 0.0 and 1.0."
|
105
|
+
]
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"cell_type": "code",
|
109
|
+
"execution_count": 5,
|
110
|
+
"metadata": {},
|
111
|
+
"outputs": [
|
112
|
+
{
|
113
|
+
"data": {
|
114
|
+
"text/plain": [
|
115
|
+
"[-4.6000142097473145, 4.779754638671875]"
|
116
|
+
]
|
117
|
+
},
|
118
|
+
"execution_count": 5,
|
119
|
+
"metadata": {},
|
120
|
+
"output_type": "execute_result"
|
121
|
+
}
|
122
|
+
],
|
123
|
+
"source": [
|
124
|
+
"[kll.get_min_value(), kll.get_max_value()]"
|
125
|
+
]
|
126
|
+
},
|
127
|
+
{
|
128
|
+
"cell_type": "code",
|
129
|
+
"execution_count": 6,
|
130
|
+
"metadata": {},
|
131
|
+
"outputs": [
|
132
|
+
{
|
133
|
+
"data": {
|
134
|
+
"text/plain": [
|
135
|
+
"[-4.6000142097473145, 4.779754638671875]"
|
136
|
+
]
|
137
|
+
},
|
138
|
+
"execution_count": 6,
|
139
|
+
"metadata": {},
|
140
|
+
"output_type": "execute_result"
|
141
|
+
}
|
142
|
+
],
|
143
|
+
"source": [
|
144
|
+
"kll.get_quantiles([0.0, 1.0])"
|
145
|
+
]
|
146
|
+
},
|
147
|
+
{
|
148
|
+
"cell_type": "markdown",
|
149
|
+
"metadata": {},
|
150
|
+
"source": [
|
151
|
+
"And out of curiosity, we can check how many items the sketch has seen and how many it is retaining"
|
152
|
+
]
|
153
|
+
},
|
154
|
+
{
|
155
|
+
"cell_type": "code",
|
156
|
+
"execution_count": 7,
|
157
|
+
"metadata": {},
|
158
|
+
"outputs": [
|
159
|
+
{
|
160
|
+
"data": {
|
161
|
+
"text/plain": [
|
162
|
+
"1000000"
|
163
|
+
]
|
164
|
+
},
|
165
|
+
"execution_count": 7,
|
166
|
+
"metadata": {},
|
167
|
+
"output_type": "execute_result"
|
168
|
+
}
|
169
|
+
],
|
170
|
+
"source": [
|
171
|
+
"kll.get_n()"
|
172
|
+
]
|
173
|
+
},
|
174
|
+
{
|
175
|
+
"cell_type": "code",
|
176
|
+
"execution_count": 8,
|
177
|
+
"metadata": {},
|
178
|
+
"outputs": [
|
179
|
+
{
|
180
|
+
"data": {
|
181
|
+
"text/plain": [
|
182
|
+
"614"
|
183
|
+
]
|
184
|
+
},
|
185
|
+
"execution_count": 8,
|
186
|
+
"metadata": {},
|
187
|
+
"output_type": "execute_result"
|
188
|
+
}
|
189
|
+
],
|
190
|
+
"source": [
|
191
|
+
"kll.get_num_retained()"
|
192
|
+
]
|
193
|
+
},
|
194
|
+
{
|
195
|
+
"cell_type": "markdown",
|
196
|
+
"metadata": {},
|
197
|
+
"source": [
|
198
|
+
"Finally, we can serialize the sketch for archiving, and reconstruct it later. Note that the serialized image does _not_ contain information on whether it is a floats or ints sketch."
|
199
|
+
]
|
200
|
+
},
|
201
|
+
{
|
202
|
+
"cell_type": "code",
|
203
|
+
"execution_count": 9,
|
204
|
+
"metadata": {},
|
205
|
+
"outputs": [
|
206
|
+
{
|
207
|
+
"data": {
|
208
|
+
"text/plain": [
|
209
|
+
"2536"
|
210
|
+
]
|
211
|
+
},
|
212
|
+
"execution_count": 9,
|
213
|
+
"metadata": {},
|
214
|
+
"output_type": "execute_result"
|
215
|
+
}
|
216
|
+
],
|
217
|
+
"source": [
|
218
|
+
"sk_bytes = kll.serialize()\n",
|
219
|
+
"len(sk_bytes)"
|
220
|
+
]
|
221
|
+
},
|
222
|
+
{
|
223
|
+
"cell_type": "code",
|
224
|
+
"execution_count": 10,
|
225
|
+
"metadata": {},
|
226
|
+
"outputs": [
|
227
|
+
{
|
228
|
+
"name": "stdout",
|
229
|
+
"output_type": "stream",
|
230
|
+
"text": [
|
231
|
+
"### KLL sketch summary:\n",
|
232
|
+
" K : 200\n",
|
233
|
+
" min K : 200\n",
|
234
|
+
" M : 8\n",
|
235
|
+
" N : 1000000\n",
|
236
|
+
" Epsilon : 1.33%\n",
|
237
|
+
" Epsilon PMF : 1.65%\n",
|
238
|
+
" Empty : false\n",
|
239
|
+
" Estimation mode: true\n",
|
240
|
+
" Levels : 13\n",
|
241
|
+
" Sorted : true\n",
|
242
|
+
" Capacity items : 617\n",
|
243
|
+
" Retained items : 614\n",
|
244
|
+
" Storage bytes : 2536\n",
|
245
|
+
" Min value : -4.6\n",
|
246
|
+
" Max value : 4.78\n",
|
247
|
+
"### End sketch summary\n",
|
248
|
+
"\n"
|
249
|
+
]
|
250
|
+
}
|
251
|
+
],
|
252
|
+
"source": [
|
253
|
+
"kll2 = kll_floats_sketch.deserialize(sk_bytes)\n",
|
254
|
+
"print(kll2)"
|
255
|
+
]
|
256
|
+
},
|
257
|
+
{
|
258
|
+
"cell_type": "markdown",
|
259
|
+
"metadata": {},
|
260
|
+
"source": [
|
261
|
+
"### Merging Sketches"
|
262
|
+
]
|
263
|
+
},
|
264
|
+
{
|
265
|
+
"cell_type": "markdown",
|
266
|
+
"metadata": {},
|
267
|
+
"source": [
|
268
|
+
"KLL sketches have a `merge()` operation to combine sketches. The resulting sketch will have no worse error boudns than if the full data had been sent to a single sketch."
|
269
|
+
]
|
270
|
+
},
|
271
|
+
{
|
272
|
+
"cell_type": "markdown",
|
273
|
+
"metadata": {},
|
274
|
+
"source": [
|
275
|
+
"Our previous sketch used $\\cal{N}(0,1)$, so now we'll generate a shifted Gaussian distributed as $\\cal{N}(4,1)$. For added variety, we can use half as many points. The next section will generate a plot, so we will defer queries of the merged skech to that section."
|
276
|
+
]
|
277
|
+
},
|
278
|
+
{
|
279
|
+
"cell_type": "code",
|
280
|
+
"execution_count": 12,
|
281
|
+
"metadata": {},
|
282
|
+
"outputs": [],
|
283
|
+
"source": [
|
284
|
+
"sk2 = kll_floats_sketch(200)\n",
|
285
|
+
"for i in range(0, int(n/2)):\n",
|
286
|
+
" sk2.update(4 + randn())"
|
287
|
+
]
|
288
|
+
},
|
289
|
+
{
|
290
|
+
"cell_type": "code",
|
291
|
+
"execution_count": 13,
|
292
|
+
"metadata": {},
|
293
|
+
"outputs": [
|
294
|
+
{
|
295
|
+
"name": "stdout",
|
296
|
+
"output_type": "stream",
|
297
|
+
"text": [
|
298
|
+
"### KLL sketch summary:\n",
|
299
|
+
" K : 200\n",
|
300
|
+
" min K : 200\n",
|
301
|
+
" M : 8\n",
|
302
|
+
" N : 1500000\n",
|
303
|
+
" Epsilon : 1.33%\n",
|
304
|
+
" Epsilon PMF : 1.65%\n",
|
305
|
+
" Empty : false\n",
|
306
|
+
" Estimation mode: true\n",
|
307
|
+
" Levels : 13\n",
|
308
|
+
" Sorted : false\n",
|
309
|
+
" Capacity items : 617\n",
|
310
|
+
" Retained items : 580\n",
|
311
|
+
" Storage bytes : 2400\n",
|
312
|
+
" Min value : -4.6\n",
|
313
|
+
" Max value : 9.06\n",
|
314
|
+
"### End sketch summary\n",
|
315
|
+
"\n"
|
316
|
+
]
|
317
|
+
}
|
318
|
+
],
|
319
|
+
"source": [
|
320
|
+
"kll.merge(sk2)\n",
|
321
|
+
"print(kll)"
|
322
|
+
]
|
323
|
+
},
|
324
|
+
{
|
325
|
+
"cell_type": "markdown",
|
326
|
+
"metadata": {},
|
327
|
+
"source": [
|
328
|
+
"### Generating Histograms"
|
329
|
+
]
|
330
|
+
},
|
331
|
+
{
|
332
|
+
"cell_type": "markdown",
|
333
|
+
"metadata": {},
|
334
|
+
"source": [
|
335
|
+
"The KLL sketch allows us compute histograms via the probability mass function (pmf). Since histograms are a typical plot type when visualizing data distributions, we will create such a figure. To instead create a cumulative distribution function (cdf) from the sketch, simply replace the call to `get_pmf()` with `get_cdf()`."
|
336
|
+
]
|
337
|
+
},
|
338
|
+
{
|
339
|
+
"cell_type": "markdown",
|
340
|
+
"metadata": {},
|
341
|
+
"source": [
|
342
|
+
"We want our x-axis to have evenly distributed bins, so the first step is to split the empirical data range\n",
|
343
|
+
"into a set of bins."
|
344
|
+
]
|
345
|
+
},
|
346
|
+
{
|
347
|
+
"cell_type": "code",
|
348
|
+
"execution_count": 14,
|
349
|
+
"metadata": {},
|
350
|
+
"outputs": [],
|
351
|
+
"source": [
|
352
|
+
"xmin = kll.get_min_value()\n",
|
353
|
+
"num_splits = 30\n",
|
354
|
+
"step = (kll.get_max_value() - xmin) / num_splits\n",
|
355
|
+
"splits = [xmin + (i*step) for i in range(0, num_splits)]"
|
356
|
+
]
|
357
|
+
},
|
358
|
+
{
|
359
|
+
"cell_type": "markdown",
|
360
|
+
"metadata": {},
|
361
|
+
"source": [
|
362
|
+
"`get_pmf()` returns the probability mass in the range $(x_{i-1}, x_i]$, for each bin $i$. If we use the minimum value for $x_{i-1}$ this covers the low end, but `get_pmf()` also returns an extra bin with all mass greater than the last-provided split point. As a result, the pmf array is 1 larger than the list of split points. We need to be sure to append a value to the split points for plotting."
|
363
|
+
]
|
364
|
+
},
|
365
|
+
{
|
366
|
+
"cell_type": "code",
|
367
|
+
"execution_count": 15,
|
368
|
+
"metadata": {},
|
369
|
+
"outputs": [],
|
370
|
+
"source": [
|
371
|
+
"pmf = kll.get_pmf(splits)\n",
|
372
|
+
"x = splits # this will hold the x-axis values, so need to append the max value\n",
|
373
|
+
"x.append(kll.get_max_value())"
|
374
|
+
]
|
375
|
+
},
|
376
|
+
{
|
377
|
+
"cell_type": "markdown",
|
378
|
+
"metadata": {},
|
379
|
+
"source": [
|
380
|
+
"We need some plotting-related imports and options"
|
381
|
+
]
|
382
|
+
},
|
383
|
+
{
|
384
|
+
"cell_type": "code",
|
385
|
+
"execution_count": 16,
|
386
|
+
"metadata": {},
|
387
|
+
"outputs": [],
|
388
|
+
"source": [
|
389
|
+
"import seaborn as sns\n",
|
390
|
+
"import matplotlib.pyplot as plt\n",
|
391
|
+
"%matplotlib inline\n",
|
392
|
+
"sns.set(color_codes=True)"
|
393
|
+
]
|
394
|
+
},
|
395
|
+
{
|
396
|
+
"cell_type": "markdown",
|
397
|
+
"metadata": {},
|
398
|
+
"source": [
|
399
|
+
"Using a negative width in the plot gives right-aligned bins, which matches the bin definition noted earlier."
|
400
|
+
]
|
401
|
+
},
|
402
|
+
{
|
403
|
+
"cell_type": "code",
|
404
|
+
"execution_count": 17,
|
405
|
+
"metadata": {},
|
406
|
+
"outputs": [
|
407
|
+
{
|
408
|
+
"data": {
|
409
|
+
"text/plain": [
|
410
|
+
"<BarContainer object of 31 artists>"
|
411
|
+
]
|
412
|
+
},
|
413
|
+
"execution_count": 17,
|
414
|
+
"metadata": {},
|
415
|
+
"output_type": "execute_result"
|
416
|
+
},
|
417
|
+
{
|
418
|
+
"data": {
|
419
|
+
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD7CAYAAABpJS8eAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAUgklEQVR4nO3dfYxc11nH8e+u7V3b8Tpt3aliJyQISh8UBHFoCCp2oCgG1IjUlCSNFKM0ahs3qigvSkVVxYHwkgoaBVcWKVQJqgPutrSuqJvWSSs3hhSqNKWKE4mkj2glAjhGmA0Q240d22v+mLvRdLu7c3d3dmdmz/cjWZp7zrnrZ95+e/fMvWcGzp07hyRp6RvsdgGSpMVh4EtSIQx8SSqEgS9JhTDwJakQy7tdwDSGgZ8CjgBnu1yLJPWLZcB64BvAqcmdvRr4PwV8tdtFSFKfugr4h8mNvRr4RwD+539OMD7eW9cJrFu3hrGx490uoxZrXRj9VCv0V73WOj+DgwO8+tXnQZWhk9UK/Ii4CdgBDAE7M/O+acY9CBzMzN3V9ibgI8AKYAx4Z2Y+V+O/PAswPn6u5wIf6MmapmOtC6OfaoX+qtdaO2LKqfC2H9pGxIXA3cBm4DJge0RcOmnMhoh4CLhh0u6fAN6VmRur27vmULgkqQPqnKWzBXg0M1/IzBPAXuD6SWO2AfuAT080RMQwsCMzn66angYunn/JkqS5qDOls4HvnQ86AlzZOiAz7wGIiM0tbaeAPVX7IHAX8Ln5lStJmqs6gT8wRdt43f8gIoaAB6v/60N194PmhyK9qNEY6XYJtVnr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
]
|
423
|
+
},
|
424
|
+
"metadata": {
|
425
|
+
"needs_background": "light"
|
426
|
+
},
|
427
|
+
"output_type": "display_data"
|
428
|
+
}
|
429
|
+
],
|
430
|
+
"source": [
|
431
|
+
"plt.bar(x=x,height=pmf,align='edge',width=-0.43)"
|
432
|
+
]
|
433
|
+
},
|
434
|
+
{
|
435
|
+
"cell_type": "markdown",
|
436
|
+
"metadata": {},
|
437
|
+
"source": [
|
438
|
+
"The leftmost peak came from the first sketch, with data centered around 0.0. The smaller, rightmost peak came from our second sketch, which had half as many samples and was centered around 4.0. The KLL sketch captures the shape of the combiend distribution."
|
439
|
+
]
|
440
|
+
}
|
441
|
+
],
|
442
|
+
"metadata": {
|
443
|
+
"kernelspec": {
|
444
|
+
"display_name": "Python 3",
|
445
|
+
"language": "python",
|
446
|
+
"name": "python3"
|
447
|
+
},
|
448
|
+
"language_info": {
|
449
|
+
"codemirror_mode": {
|
450
|
+
"name": "ipython",
|
451
|
+
"version": 3
|
452
|
+
},
|
453
|
+
"file_extension": ".py",
|
454
|
+
"mimetype": "text/x-python",
|
455
|
+
"name": "python",
|
456
|
+
"nbconvert_exporter": "python",
|
457
|
+
"pygments_lexer": "ipython3",
|
458
|
+
"version": "3.7.0"
|
459
|
+
}
|
460
|
+
},
|
461
|
+
"nbformat": 4,
|
462
|
+
"nbformat_minor": 2
|
463
|
+
}
|