| <!DOCTYPE html> |
| <html class="writer-html5" lang="en" > |
| <head> |
| <meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" /> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| <title>Theta Sketch — datasketches 0.1 documentation</title> |
| <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> |
| <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> |
| <!--[if lt IE 9]> |
| <script src="_static/js/html5shiv.min.js"></script> |
| <![endif]--> |
| |
| <script src="_static/jquery.js?v=5d32c60e"></script> |
| <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script> |
| <script src="_static/documentation_options.js?v=2709fde1"></script> |
| <script src="_static/doctools.js?v=888ff710"></script> |
| <script src="_static/sphinx_highlight.js?v=dc90522c"></script> |
| <script src="_static/js/theme.js"></script> |
| <link rel="index" title="Index" href="genindex.html" /> |
| <link rel="search" title="Search" href="search.html" /> |
| <link rel="next" title="Tuple Sketch" href="tuple.html" /> |
| <link rel="prev" title="Compressed Probabilistic Counting (CPC)" href="cpc.html" /> |
| </head> |
| |
| <body class="wy-body-for-nav"> |
| <div class="wy-grid-for-nav"> |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-scroll"> |
| <div class="wy-side-nav-search" > |
| |
| |
| |
| <a href="index.html" class="icon icon-home"> |
| datasketches |
| </a> |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="hyper_log_log.html">HyperLogLog</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="cpc.html">Compressed Probabilistic Counting (CPC)</a></li> |
| <li class="toctree-l1 current"><a class="current reference internal" href="#">Theta Sketch</a><ul> |
| <li class="toctree-l2"><a class="reference internal" href="#datasketches.theta_sketch"><code class="docutils literal notranslate"><span class="pre">theta_sketch</span></code></a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#datasketches.theta_sketch.get_estimate"><code class="docutils literal notranslate"><span class="pre">theta_sketch.get_estimate()</span></code></a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#datasketches.theta_sketch.get_lower_bound"><code class="docutils literal notranslate"><span class="pre">theta_sketch.get_lower_bound()</span></code></a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#datasketches.theta_sketch.get_num_retained"><code class="docutils literal notranslate"><span class="pre">theta_sketch.get_num_retained()</span></code></a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#datasketches.theta_sketch.get_seed_hash"><code class="docutils literal notranslate"><span class="pre">theta_sketch.get_seed_hash()</span></code></a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#datasketches.theta_sketch.get_theta"><code class="docutils literal notranslate"><span class="pre">theta_sketch.get_theta()</span></code></a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#datasketches.theta_sketch.get_theta64"><code class="docutils literal notranslate"><span class="pre">theta_sketch.get_theta64()</span></code></a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#datasketches.theta_sketch.get_upper_bound"><code class="docutils literal notranslate"><span class="pre">theta_sketch.get_upper_bound()</span></code></a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#datasketches.theta_sketch.is_empty"><code class="docutils literal notranslate"><span class="pre">theta_sketch.is_empty()</span></code></a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#datasketches.theta_sketch.is_estimation_mode"><code class="docutils literal notranslate"><span class="pre">theta_sketch.is_estimation_mode()</span></code></a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#datasketches.theta_sketch.is_ordered"><code class="docutils literal notranslate"><span class="pre">theta_sketch.is_ordered()</span></code></a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#datasketches.theta_sketch.to_string"><code class="docutils literal notranslate"><span class="pre">theta_sketch.to_string()</span></code></a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="tuple.html">Tuple Sketch</a></li> |
| </ul> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="density_sketch.html">Density Sketch</a></li> |
| </ul> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="count_min_sketch.html">CountMin Sketch</a></li> |
| </ul> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="frequent_items.html">Frequent Items</a></li> |
| </ul> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="kll.html">KLL Sketch</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="req.html">Relative Error Quantiles (REQ) Sketch</a></li> |
| </ul> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="datasketches.html">Python DataSketches</a></li> |
| </ul> |
| |
| </div> |
| </div> |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="index.html">datasketches</a> |
| </nav> |
| |
| <div class="wy-nav-content"> |
| <div class="rst-content"> |
| <div role="navigation" aria-label="Page navigation"> |
| <ul class="wy-breadcrumbs"> |
| <li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li> |
| <li class="breadcrumb-item active">Theta Sketch</li> |
| <li class="wy-breadcrumbs-aside"> |
| <a href="_sources/theta.rst.txt" rel="nofollow"> View page source</a> |
| </li> |
| </ul> |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <section id="theta-sketch"> |
| <h1>Theta Sketch<a class="headerlink" href="#theta-sketch" title="Link to this heading"></a></h1> |
| <p>The <em>Theta Sketch</em> sketch is a space-efficient method for estimating cardinalities of sets. |
| It can also easily handle set operations (such as union, intersection, difference) while maintaining good accuarcy.</p> |
| <dl class="py class"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch"> |
| <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">_datasketches.</span></span><span class="sig-name descname"><span class="pre">theta_sketch</span></span><a class="headerlink" href="#datasketches.theta_sketch" title="Link to this definition"></a></dt> |
| <dd><dl class="py method"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch.get_estimate"> |
| <span class="sig-name descname"><span class="pre">get_estimate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.theta_sketch" title="_datasketches.theta_sketch"><span class="pre">_datasketches.theta_sketch</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="headerlink" href="#datasketches.theta_sketch.get_estimate" title="Link to this definition"></a></dt> |
| <dd><p>Estimate of the distinct count of the input stream</p> |
| </dd></dl> |
| |
| <dl class="py method"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch.get_lower_bound"> |
| <span class="sig-name descname"><span class="pre">get_lower_bound</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.theta_sketch" title="_datasketches.theta_sketch"><span class="pre">_datasketches.theta_sketch</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_std_devs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="headerlink" href="#datasketches.theta_sketch.get_lower_bound" title="Link to this definition"></a></dt> |
| <dd><p>Returns an approximate lower bound on the estimate at standard deviations in {1, 2, 3}</p> |
| </dd></dl> |
| |
| <dl class="py method"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch.get_num_retained"> |
| <span class="sig-name descname"><span class="pre">get_num_retained</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.theta_sketch" title="_datasketches.theta_sketch"><span class="pre">_datasketches.theta_sketch</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#datasketches.theta_sketch.get_num_retained" title="Link to this definition"></a></dt> |
| <dd><p>Returns the number of items currently in the sketch</p> |
| </dd></dl> |
| |
| <dl class="py method"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch.get_seed_hash"> |
| <span class="sig-name descname"><span class="pre">get_seed_hash</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.theta_sketch" title="_datasketches.theta_sketch"><span class="pre">_datasketches.theta_sketch</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#datasketches.theta_sketch.get_seed_hash" title="Link to this definition"></a></dt> |
| <dd><p>Returns a hash of the seed used in the sketch</p> |
| </dd></dl> |
| |
| <dl class="py method"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch.get_theta"> |
| <span class="sig-name descname"><span class="pre">get_theta</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.theta_sketch" title="_datasketches.theta_sketch"><span class="pre">_datasketches.theta_sketch</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="headerlink" href="#datasketches.theta_sketch.get_theta" title="Link to this definition"></a></dt> |
| <dd><p>Returns theta (effective sampling rate) as a fraction from 0 to 1</p> |
| </dd></dl> |
| |
| <dl class="py method"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch.get_theta64"> |
| <span class="sig-name descname"><span class="pre">get_theta64</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.theta_sketch" title="_datasketches.theta_sketch"><span class="pre">_datasketches.theta_sketch</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#datasketches.theta_sketch.get_theta64" title="Link to this definition"></a></dt> |
| <dd><p>Returns theta as 64-bit value</p> |
| </dd></dl> |
| |
| <dl class="py method"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch.get_upper_bound"> |
| <span class="sig-name descname"><span class="pre">get_upper_bound</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.theta_sketch" title="_datasketches.theta_sketch"><span class="pre">_datasketches.theta_sketch</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_std_devs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="headerlink" href="#datasketches.theta_sketch.get_upper_bound" title="Link to this definition"></a></dt> |
| <dd><p>Returns an approximate upper bound on the estimate at standard deviations in {1, 2, 3}</p> |
| </dd></dl> |
| |
| <dl class="py method"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch.is_empty"> |
| <span class="sig-name descname"><span class="pre">is_empty</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.theta_sketch" title="_datasketches.theta_sketch"><span class="pre">_datasketches.theta_sketch</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">bool</span></span></span><a class="headerlink" href="#datasketches.theta_sketch.is_empty" title="Link to this definition"></a></dt> |
| <dd><p>Returns True if the sketch is empty, otherwise False</p> |
| </dd></dl> |
| |
| <dl class="py method"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch.is_estimation_mode"> |
| <span class="sig-name descname"><span class="pre">is_estimation_mode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.theta_sketch" title="_datasketches.theta_sketch"><span class="pre">_datasketches.theta_sketch</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">bool</span></span></span><a class="headerlink" href="#datasketches.theta_sketch.is_estimation_mode" title="Link to this definition"></a></dt> |
| <dd><p>Returns True if sketch is in estimation mode, otherwise False</p> |
| </dd></dl> |
| |
| <dl class="py method"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch.is_ordered"> |
| <span class="sig-name descname"><span class="pre">is_ordered</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.theta_sketch" title="_datasketches.theta_sketch"><span class="pre">_datasketches.theta_sketch</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">bool</span></span></span><a class="headerlink" href="#datasketches.theta_sketch.is_ordered" title="Link to this definition"></a></dt> |
| <dd><p>Returns True if the sketch entries are sorted, otherwise False</p> |
| </dd></dl> |
| |
| <dl class="py method"> |
| <dt class="sig sig-object py" id="datasketches.theta_sketch.to_string"> |
| <span class="sig-name descname"><span class="pre">to_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.theta_sketch" title="_datasketches.theta_sketch"><span class="pre">_datasketches.theta_sketch</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">print_items</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="headerlink" href="#datasketches.theta_sketch.to_string" title="Link to this definition"></a></dt> |
| <dd><p>Produces a string summary of the sketch</p> |
| </dd></dl> |
| |
| </dd></dl> |
| |
| </section> |
| |
| |
| </div> |
| </div> |
| <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> |
| <a href="cpc.html" class="btn btn-neutral float-left" title="Compressed Probabilistic Counting (CPC)" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> |
| <a href="tuple.html" class="btn btn-neutral float-right" title="Tuple Sketch" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> |
| </div> |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p>© Copyright .</p> |
| </div> |
| |
| Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a |
| <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> |
| provided by <a href="https://readthedocs.org">Read the Docs</a>. |
| |
| |
| </footer> |
| </div> |
| </div> |
| </section> |
| </div> |
| <script> |
| jQuery(function () { |
| SphinxRtdTheme.Navigation.enable(true); |
| }); |
| </script> |
| |
| </body> |
| </html> |