blob: 89ceeebf165323d61eb91b7cc1de038c29b1fa0f [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_162) on Thu Oct 25 17:06:10 PDT 2018 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DoublesSketch (com.yahoo.datasketches:sketches-core 0.12.1-SNAPSHOT API)</title>
<meta name="date" content="2018-10-25">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="DoublesSketch (com.yahoo.datasketches:sketches-core 0.12.1-SNAPSHOT API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":9,"i1":10,"i2":10,"i3":10,"i4":9,"i5":10,"i6":9,"i7":6,"i8":6,"i9":6,"i10":42,"i11":10,"i12":41,"i13":9,"i14":10,"i15":10,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10,"i21":10,"i22":10,"i23":10,"i24":9,"i25":9,"i26":6,"i27":10,"i28":10,"i29":10,"i30":10,"i31":10,"i32":10,"i33":10,"i34":10,"i35":10,"i36":10,"i37":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],8:["t4","Concrete Methods"],32:["t6","Deprecated Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/DoublesSketch.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../com/yahoo/sketches/quantiles/CompactDoublesSketch.html" title="class in com.yahoo.sketches.quantiles"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketchBuilder.html" title="class in com.yahoo.sketches.quantiles"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?com/yahoo/sketches/quantiles/DoublesSketch.html" target="_top">Frames</a></li>
<li><a href="DoublesSketch.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">com.yahoo.sketches.quantiles</div>
<h2 title="Class DoublesSketch" class="title">Class DoublesSketch</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>com.yahoo.sketches.quantiles.DoublesSketch</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>Direct Known Subclasses:</dt>
<dd><a href="../../../../com/yahoo/sketches/quantiles/CompactDoublesSketch.html" title="class in com.yahoo.sketches.quantiles">CompactDoublesSketch</a>, <a href="../../../../com/yahoo/sketches/quantiles/UpdateDoublesSketch.html" title="class in com.yahoo.sketches.quantiles">UpdateDoublesSketch</a></dd>
</dl>
<hr>
<br>
<pre>public abstract class <span class="typeNameLabel">DoublesSketch</span>
extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
<div class="block">This is a stochastic streaming sketch that enables near-real time analysis of the
approximate distribution of real values from a very large stream in a single pass.
The analysis is obtained using a getQuantiles(*) function or its inverse functions the
Probability Mass Function from getPMF(*) and the Cumulative Distribution Function from getCDF(*).
<p>Consider a large stream of one million values such as packet sizes coming into a network node.
The absolute rank of any specific size value is simply its index in the hypothetical sorted
array of values.
The normalized rank (or fractional rank) is the absolute rank divided by the stream size,
in this case one million.
The value corresponding to the normalized rank of 0.5 represents the 50th percentile or median
value of the distribution, or getQuantile(0.5). Similarly, the 95th percentile is obtained from
getQuantile(0.95). Using the getQuantiles(0.0, 1.0) will return the min and max values seen by
the sketch.</p>
<p>From the min and max values, for example, 1 and 1000 bytes,
you can obtain the PMF from getPMF(100, 500, 900) that will result in an array of
4 fractional values such as {.4, .3, .2, .1}, which means that
<ul>
<li>40% of the values were &lt; 100,</li>
<li>30% of the values were &ge; 100 and &lt; 500,</li>
<li>20% of the values were &ge; 500 and &lt; 900, and</li>
<li>10% of the values were &ge; 900.</li>
</ul>
A frequency histogram can be obtained by simply multiplying these fractions by getN(),
which is the total count of values received.
The getCDF(*) works similarly, but produces the cumulative distribution instead.
<p>The accuracy of this sketch is a function of the configured value <i>k</i>, which also affects
the overall size of the sketch. Accuracy of this quantile sketch is always with respect to
the normalized rank. A <i>k</i> of 128 produces a normalized, rank error of about 1.7%.
For example, the median value returned from getQuantile(0.5) will be between the actual values
from the hypothetically sorted array of input values at normalized ranks of 0.483 and 0.517, with
a confidence of about 99%.</p>
<pre>
Table Guide for DoublesSketch Size in Bytes and Approximate Error:
K =&gt; | 16 32 64 128 256 512 1,024
~ Error =&gt; | 12.145% 6.359% 3.317% 1.725% 0.894% 0.463% 0.239%
N | Size in Bytes -&gt;
------------------------------------------------------------------------
0 | 8 8 8 8 8 8 8
1 | 72 72 72 72 72 72 72
3 | 72 72 72 72 72 72 72
7 | 104 104 104 104 104 104 104
15 | 168 168 168 168 168 168 168
31 | 296 296 296 296 296 296 296
63 | 424 552 552 552 552 552 552
127 | 552 808 1,064 1,064 1,064 1,064 1,064
255 | 680 1,064 1,576 2,088 2,088 2,088 2,088
511 | 808 1,320 2,088 3,112 4,136 4,136 4,136
1,023 | 936 1,576 2,600 4,136 6,184 8,232 8,232
2,047 | 1,064 1,832 3,112 5,160 8,232 12,328 16,424
4,095 | 1,192 2,088 3,624 6,184 10,280 16,424 24,616
8,191 | 1,320 2,344 4,136 7,208 12,328 20,520 32,808
16,383 | 1,448 2,600 4,648 8,232 14,376 24,616 41,000
32,767 | 1,576 2,856 5,160 9,256 16,424 28,712 49,192
65,535 | 1,704 3,112 5,672 10,280 18,472 32,808 57,384
131,071 | 1,832 3,368 6,184 11,304 20,520 36,904 65,576
262,143 | 1,960 3,624 6,696 12,328 22,568 41,000 73,768
524,287 | 2,088 3,880 7,208 13,352 24,616 45,096 81,960
1,048,575 | 2,216 4,136 7,720 14,376 26,664 49,192 90,152
2,097,151 | 2,344 4,392 8,232 15,400 28,712 53,288 98,344
4,194,303 | 2,472 4,648 8,744 16,424 30,760 57,384 106,536
8,388,607 | 2,600 4,904 9,256 17,448 32,808 61,480 114,728
16,777,215 | 2,728 5,160 9,768 18,472 34,856 65,576 122,920
33,554,431 | 2,856 5,416 10,280 19,496 36,904 69,672 131,112
67,108,863 | 2,984 5,672 10,792 20,520 38,952 73,768 139,304
134,217,727 | 3,112 5,928 11,304 21,544 41,000 77,864 147,496
268,435,455 | 3,240 6,184 11,816 22,568 43,048 81,960 155,688
536,870,911 | 3,368 6,440 12,328 23,592 45,096 86,056 163,880
1,073,741,823 | 3,496 6,696 12,840 24,616 47,144 90,152 172,072
2,147,483,647 | 3,624 6,952 13,352 25,640 49,192 94,248 180,264
4,294,967,295 | 3,752 7,208 13,864 26,664 51,240 98,344 188,456
</pre>
<p>There is more documentation available on
<a href="https://datasketches.github.io">DataSketches.GitHub.io</a>.</p>
<p>This is an implementation of the Low Discrepancy Mergeable Quantiles Sketch, using double
values, described in section 3.2 of the journal version of the paper "Mergeable Summaries"
by Agarwal, Cormode, Huang, Phillips, Wei, and Yi.
<a href="http://dblp.org/rec/html/journals/tods/AgarwalCHPWY13"></a></p>
<p>This algorithm is independent of the distribution of values, which can be anywhere in the
range of the IEEE-754 64-bit doubles.
<p>This algorithm intentionally inserts randomness into the sampling process for values that
ultimately get retained in the sketch. The results produced by this algorithm are not
deterministic. For example, if the same stream is inserted into two different instances of this
sketch, the answers obtained from the two sketches may not be be identical.</p>
<p>Similarly, there may be directional inconsistencies. For example, the resulting array of
values obtained from getQuantiles(fractions[]) input into the reverse directional query
getPMF(splitPoints[]) may not result in the original fractional values.</p></div>
<dl>
<dt><span class="simpleTagLabel">Author:</span></dt>
<dd>Kevin Lang, Lee Rhodes, Jon Malkin</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Random.html?is-external=true" title="class or interface in java.util">Random</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#rand">rand</a></span></code>
<div class="block">Setting the seed makes the results of the sketch deterministic if the input values are
received in exactly the same order.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t6" class="tableTab"><span><a href="javascript:show(32);">Deprecated Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>static <a href="../../../../com/yahoo/sketches/quantiles/DoublesSketchBuilder.html" title="class in com.yahoo.sketches.quantiles">DoublesSketchBuilder</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#builder--">builder</a></span>()</code>
<div class="block">Returns a new builder</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html" title="class in com.yahoo.sketches.quantiles">DoublesSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#downSample-com.yahoo.sketches.quantiles.DoublesSketch-int-com.yahoo.memory.WritableMemory-">downSample</a></span>(<a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html" title="class in com.yahoo.sketches.quantiles">DoublesSketch</a>&nbsp;srcSketch,
int&nbsp;smallerK,
com.yahoo.memory.WritableMemory&nbsp;dstMem)</code>
<div class="block">From an source sketch, create a new sketch that must have a smaller value of K.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>double[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getCDF-double:A-">getCDF</a></span>(double[]&nbsp;splitPoints)</code>
<div class="block">Returns an approximation to the Cumulative Distribution Function (CDF), which is the
cumulative analog of the PMF, of the input stream given a set of splitPoint (values).</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getCompactStorageBytes--">getCompactStorageBytes</a></span>()</code>
<div class="block">Returns the number of bytes this sketch would require to store in compact form, which is not
updatable.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getCompactStorageBytes-int-long-">getCompactStorageBytes</a></span>(int&nbsp;k,
long&nbsp;n)</code>
<div class="block">Returns the number of bytes a DoublesSketch would require to store in compact form
given the values of <i>k</i> and <i>n</i>.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getK--">getK</a></span>()</code>
<div class="block">Returns the configured value of K</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getKFromEpsilon-double-boolean-">getKFromEpsilon</a></span>(double&nbsp;epsilon,
boolean&nbsp;pmf)</code>
<div class="block">Gets the approximate value of <em>k</em> to use given epsilon, the normalized rank error.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>abstract double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getMaxValue--">getMaxValue</a></span>()</code>
<div class="block">Returns the max value of the stream.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>abstract double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getMinValue--">getMinValue</a></span>()</code>
<div class="block">Returns the min value of the stream.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>abstract long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getN--">getN</a></span>()</code>
<div class="block">Returns the length of the input stream so far.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getNormalizedRankError--">getNormalizedRankError</a></span>()</code>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;
<div class="block"><span class="deprecationComment">replaced by <a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getNormalizedRankError-boolean-"><code>getNormalizedRankError(boolean)</code></a></span></div>
</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getNormalizedRankError-boolean-">getNormalizedRankError</a></span>(boolean&nbsp;pmf)</code>
<div class="block">Gets the approximate rank error of this sketch normalized as a fraction between zero and one.</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getNormalizedRankError-int-">getNormalizedRankError</a></span>(int&nbsp;k)</code>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;
<div class="block"><span class="deprecationComment">replaced by <a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getNormalizedRankError-int-boolean-"><code>getNormalizedRankError(int, boolean)</code></a></span></div>
</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getNormalizedRankError-int-boolean-">getNormalizedRankError</a></span>(int&nbsp;k,
boolean&nbsp;pmf)</code>
<div class="block">Gets the normalized rank error given k and pmf.</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code>double[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getPMF-double:A-">getPMF</a></span>(double[]&nbsp;splitPoints)</code>
<div class="block">Returns an approximation to the Probability Mass Function (PMF) of the input stream
given a set of splitPoints (values).</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getQuantile-double-">getQuantile</a></span>(double&nbsp;fraction)</code>
<div class="block">This returns an approximation to the value of the data item
that would be preceded by the given fraction of a hypothetical sorted
version of the input stream so far.</div>
</td>
</tr>
<tr id="i16" class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getQuantileLowerBound-double-">getQuantileLowerBound</a></span>(double&nbsp;fraction)</code>
<div class="block">Gets the lower bound of the value interval in which the true quantile of the given rank
exists with a confidence of at least 99%.</div>
</td>
</tr>
<tr id="i17" class="rowColor">
<td class="colFirst"><code>double[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getQuantiles-double:A-">getQuantiles</a></span>(double[]&nbsp;fractions)</code>
<div class="block">This is a more efficient multiple-query version of getQuantile().</div>
</td>
</tr>
<tr id="i18" class="altColor">
<td class="colFirst"><code>double[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getQuantiles-int-">getQuantiles</a></span>(int&nbsp;evenlySpaced)</code>
<div class="block">This is also a more efficient multiple-query version of getQuantile() and allows the caller to
specify the number of evenly spaced fractional ranks.</div>
</td>
</tr>
<tr id="i19" class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getQuantileUpperBound-double-">getQuantileUpperBound</a></span>(double&nbsp;fraction)</code>
<div class="block">Gets the upper bound of the value interval in which the true quantile of the given rank
exists with a confidence of at least 99%.</div>
</td>
</tr>
<tr id="i20" class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getRank-double-">getRank</a></span>(double&nbsp;value)</code>
<div class="block">Returns an approximation to the normalized (fractional) rank of the given value from 0 to 1
inclusive.</div>
</td>
</tr>
<tr id="i21" class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getRetainedItems--">getRetainedItems</a></span>()</code>
<div class="block">Computes the number of retained items (samples) in the sketch</div>
</td>
</tr>
<tr id="i22" class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getStorageBytes--">getStorageBytes</a></span>()</code>
<div class="block">Returns the number of bytes this sketch would require to store in native form: compact for
a CompactDoublesSketch, non-compact for an UpdateDoublesSketch.</div>
</td>
</tr>
<tr id="i23" class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getUpdatableStorageBytes--">getUpdatableStorageBytes</a></span>()</code>
<div class="block">Returns the number of bytes this sketch would require to store in updatable form.</div>
</td>
</tr>
<tr id="i24" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getUpdatableStorageBytes-int-long-">getUpdatableStorageBytes</a></span>(int&nbsp;k,
long&nbsp;n)</code>
<div class="block">Returns the number of bytes a sketch would require to store in updatable form.</div>
</td>
</tr>
<tr id="i25" class="rowColor">
<td class="colFirst"><code>static <a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html" title="class in com.yahoo.sketches.quantiles">DoublesSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#heapify-com.yahoo.memory.Memory-">heapify</a></span>(com.yahoo.memory.Memory&nbsp;srcMem)</code>
<div class="block">Heapify takes the sketch image in Memory and instantiates an on-heap Sketch.</div>
</td>
</tr>
<tr id="i26" class="altColor">
<td class="colFirst"><code>abstract boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#isDirect--">isDirect</a></span>()</code>
<div class="block">Returns true if this sketch is direct</div>
</td>
</tr>
<tr id="i27" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#isEmpty--">isEmpty</a></span>()</code>
<div class="block">Returns true if this sketch is empty</div>
</td>
</tr>
<tr id="i28" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#isEstimationMode--">isEstimationMode</a></span>()</code>
<div class="block">Returns true if this sketch is in estimation mode.</div>
</td>
</tr>
<tr id="i29" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#isSameResource-com.yahoo.memory.Memory-">isSameResource</a></span>(com.yahoo.memory.Memory&nbsp;that)</code>
<div class="block">Returns true if the backing resource of <i>this</i> is identical with the backing resource
of <i>that</i>.</div>
</td>
</tr>
<tr id="i30" class="altColor">
<td class="colFirst"><code><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketchIterator.html" title="class in com.yahoo.sketches.quantiles">DoublesSketchIterator</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#iterator--">iterator</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i31" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#putMemory-com.yahoo.memory.WritableMemory-">putMemory</a></span>(com.yahoo.memory.WritableMemory&nbsp;dstMem)</code>
<div class="block">Puts the current sketch into the given Memory in compact form if there is sufficient space,
otherwise, it throws an error.</div>
</td>
</tr>
<tr id="i32" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#putMemory-com.yahoo.memory.WritableMemory-boolean-">putMemory</a></span>(com.yahoo.memory.WritableMemory&nbsp;dstMem,
boolean&nbsp;compact)</code>
<div class="block">Puts the current sketch into the given Memory if there is sufficient space, otherwise,
throws an error.</div>
</td>
</tr>
<tr id="i33" class="rowColor">
<td class="colFirst"><code>byte[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#toByteArray--">toByteArray</a></span>()</code>
<div class="block">Serialize this sketch to a byte array.</div>
</td>
</tr>
<tr id="i34" class="altColor">
<td class="colFirst"><code>byte[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#toByteArray-boolean-">toByteArray</a></span>(boolean&nbsp;compact)</code>
<div class="block">Serialize this sketch in a byte array form.</div>
</td>
</tr>
<tr id="i35" class="rowColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#toString--">toString</a></span>()</code>
<div class="block">Returns summary information about this sketch.</div>
</td>
</tr>
<tr id="i36" class="altColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#toString-boolean-boolean-">toString</a></span>(boolean&nbsp;sketchSummary,
boolean&nbsp;dataDetail)</code>
<div class="block">Returns summary information about this sketch.</div>
</td>
</tr>
<tr id="i37" class="rowColor">
<td class="colFirst"><code>static <a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html" title="class in com.yahoo.sketches.quantiles">DoublesSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#wrap-com.yahoo.memory.Memory-">wrap</a></span>(com.yahoo.memory.Memory&nbsp;srcMem)</code>
<div class="block">Wrap this sketch around the given Memory image of a DoublesSketch, compact or non-compact.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="rand">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>rand</h4>
<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Random.html?is-external=true" title="class or interface in java.util">Random</a> rand</pre>
<div class="block">Setting the seed makes the results of the sketch deterministic if the input values are
received in exactly the same order. This is only useful when performing test comparisons,
otherwise is not recommended.</div>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="builder--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>builder</h4>
<pre>public static final&nbsp;<a href="../../../../com/yahoo/sketches/quantiles/DoublesSketchBuilder.html" title="class in com.yahoo.sketches.quantiles">DoublesSketchBuilder</a>&nbsp;builder()</pre>
<div class="block">Returns a new builder</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a new builder</dd>
</dl>
</li>
</ul>
<a name="heapify-com.yahoo.memory.Memory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>heapify</h4>
<pre>public static&nbsp;<a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html" title="class in com.yahoo.sketches.quantiles">DoublesSketch</a>&nbsp;heapify(com.yahoo.memory.Memory&nbsp;srcMem)</pre>
<div class="block">Heapify takes the sketch image in Memory and instantiates an on-heap Sketch.
The resulting sketch will not retain any link to the source Memory.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>srcMem</code> - a Memory image of a Sketch.
<a href="../../../../resources/dictionary.html#mem">See Memory</a></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a heap-based Sketch based on the given Memory</dd>
</dl>
</li>
</ul>
<a name="wrap-com.yahoo.memory.Memory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>wrap</h4>
<pre>public static&nbsp;<a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html" title="class in com.yahoo.sketches.quantiles">DoublesSketch</a>&nbsp;wrap(com.yahoo.memory.Memory&nbsp;srcMem)</pre>
<div class="block">Wrap this sketch around the given Memory image of a DoublesSketch, compact or non-compact.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>srcMem</code> - the given Memory image of a DoublesSketch that may have data,</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a sketch that wraps the given srcMem</dd>
</dl>
</li>
</ul>
<a name="getQuantile-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getQuantile</h4>
<pre>public&nbsp;double&nbsp;getQuantile(double&nbsp;fraction)</pre>
<div class="block">This returns an approximation to the value of the data item
that would be preceded by the given fraction of a hypothetical sorted
version of the input stream so far.
<p>We note that this method has a fairly large overhead (microseconds instead of nanoseconds)
so it should not be called multiple times to get different quantiles from the same
sketch. Instead use getQuantiles(), which pays the overhead only once.
<p>If the sketch is empty this returns Double.NaN.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>fraction</code> - the specified fractional position in the hypothetical sorted stream.
These are also called normalized ranks or fractional ranks.
If fraction = 0.0, the true minimum value of the stream is returned.
If fraction = 1.0, the true maximum value of the stream is returned.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the approximation to the value at the above fraction</dd>
</dl>
</li>
</ul>
<a name="getQuantileUpperBound-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getQuantileUpperBound</h4>
<pre>public&nbsp;double&nbsp;getQuantileUpperBound(double&nbsp;fraction)</pre>
<div class="block">Gets the upper bound of the value interval in which the true quantile of the given rank
exists with a confidence of at least 99%.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>fraction</code> - the given normalized rank as a fraction</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the upper bound of the value interval in which the true quantile of the given rank
exists with a confidence of at least 99%. Returns NaN if the sketch is empty.</dd>
</dl>
</li>
</ul>
<a name="getQuantileLowerBound-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getQuantileLowerBound</h4>
<pre>public&nbsp;double&nbsp;getQuantileLowerBound(double&nbsp;fraction)</pre>
<div class="block">Gets the lower bound of the value interval in which the true quantile of the given rank
exists with a confidence of at least 99%.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>fraction</code> - the given normalized rank as a fraction</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the lower bound of the value interval in which the true quantile of the given rank
exists with a confidence of at least 99%. Returns NaN if the sketch is empty.</dd>
</dl>
</li>
</ul>
<a name="getQuantiles-double:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getQuantiles</h4>
<pre>public&nbsp;double[]&nbsp;getQuantiles(double[]&nbsp;fractions)</pre>
<div class="block">This is a more efficient multiple-query version of getQuantile().
<p>This returns an array that could have been generated by using getQuantile() with many different
fractional ranks, but would be very inefficient.
This method incurs the internal set-up overhead once and obtains multiple quantile values in
a single query. It is strongly recommend that this method be used instead of multiple calls
to getQuantile().
<p>If the sketch is empty this returns null.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>fractions</code> - given array of fractional positions in the hypothetical sorted stream.
These are also called normalized ranks or fractional ranks.
These fractions must be monotonic, in increasing order and in the interval
[0.0, 1.0] inclusive.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>array of approximations to the given fractions in the same order as given fractions
array.</dd>
</dl>
</li>
</ul>
<a name="getQuantiles-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getQuantiles</h4>
<pre>public&nbsp;double[]&nbsp;getQuantiles(int&nbsp;evenlySpaced)</pre>
<div class="block">This is also a more efficient multiple-query version of getQuantile() and allows the caller to
specify the number of evenly spaced fractional ranks.
<p>If the sketch is empty this returns null.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>evenlySpaced</code> - an integer that specifies the number of evenly spaced fractional ranks.
This must be a positive integer greater than 0. A value of 1 will return the min value.
A value of 2 will return the min and the max value. A value of 3 will return the min,
the median and the max value, etc.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>array of approximations to the given fractions in the same order as given fractions
array.</dd>
</dl>
</li>
</ul>
<a name="getRank-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getRank</h4>
<pre>public&nbsp;double&nbsp;getRank(double&nbsp;value)</pre>
<div class="block">Returns an approximation to the normalized (fractional) rank of the given value from 0 to 1
inclusive.
<p>The resulting approximation has a probabilistic guarantee that be obtained from the
getNormalizedRankError(false) function.
<p>If the sketch is empty this returns NaN.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>value</code> - to be ranked</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an approximate rank of the given value</dd>
</dl>
</li>
</ul>
<a name="getPMF-double:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getPMF</h4>
<pre>public&nbsp;double[]&nbsp;getPMF(double[]&nbsp;splitPoints)</pre>
<div class="block">Returns an approximation to the Probability Mass Function (PMF) of the input stream
given a set of splitPoints (values).
<p>The resulting approximations have a probabilistic guarantee that be obtained from the
getNormalizedRankError(true) function.
<p>If the sketch is empty this returns null.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>splitPoints</code> - an array of <i>m</i> unique, monotonically increasing double values
that divide the real number line into <i>m+1</i> consecutive disjoint intervals.
The definition of an "interval" is inclusive of the left splitPoint (or minimum value) and
exclusive of the right splitPoint, with the exception that the last interval will include
the maximum value.
It is not necessary to include either the min or max values in these splitpoints.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an array of m+1 doubles each of which is an approximation
to the fraction of the input stream values (the mass) that fall into one of those intervals.
The definition of an "interval" is inclusive of the left splitPoint and exclusive of the right
splitPoint, with the exception that the last interval will include maximum value.</dd>
</dl>
</li>
</ul>
<a name="getCDF-double:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCDF</h4>
<pre>public&nbsp;double[]&nbsp;getCDF(double[]&nbsp;splitPoints)</pre>
<div class="block">Returns an approximation to the Cumulative Distribution Function (CDF), which is the
cumulative analog of the PMF, of the input stream given a set of splitPoint (values).
<p>The resulting approximations have a probabilistic guarantee that be obtained from the
getNormalizedRankError(false) function.
<p>If the sketch is empty this returns null.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>splitPoints</code> - an array of <i>m</i> unique, monotonically increasing double values
that divide the real number line into <i>m+1</i> consecutive disjoint intervals.
The definition of an "interval" is inclusive of the left splitPoint (or minimum value) and
exclusive of the right splitPoint, with the exception that the last interval will include
the maximum value.
It is not necessary to include either the min or max values in these splitpoints.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an array of m+1 double values, which are a consecutive approximation to the CDF
of the input stream given the splitPoints. The value at array position j of the returned
CDF array is the sum of the returned values in positions 0 through j of the returned PMF
array.</dd>
</dl>
</li>
</ul>
<a name="getK--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getK</h4>
<pre>public&nbsp;int&nbsp;getK()</pre>
<div class="block">Returns the configured value of K</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the configured value of K</dd>
</dl>
</li>
</ul>
<a name="getMinValue--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getMinValue</h4>
<pre>public abstract&nbsp;double&nbsp;getMinValue()</pre>
<div class="block">Returns the min value of the stream.
If the sketch is empty this returns Double.NaN.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the min value of the stream</dd>
</dl>
</li>
</ul>
<a name="getMaxValue--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getMaxValue</h4>
<pre>public abstract&nbsp;double&nbsp;getMaxValue()</pre>
<div class="block">Returns the max value of the stream.
If the sketch is empty this returns Double.NaN.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the max value of the stream</dd>
</dl>
</li>
</ul>
<a name="getN--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getN</h4>
<pre>public abstract&nbsp;long&nbsp;getN()</pre>
<div class="block">Returns the length of the input stream so far.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the length of the input stream so far</dd>
</dl>
</li>
</ul>
<a name="getNormalizedRankError--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getNormalizedRankError</h4>
<pre><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
public&nbsp;double&nbsp;getNormalizedRankError()</pre>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;<span class="deprecationComment">replaced by <a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getNormalizedRankError-boolean-"><code>getNormalizedRankError(boolean)</code></a></span></div>
<div class="block">Get the rank error normalized as a fraction between zero and one.
The error of this sketch is specified as a fraction of the normalized rank of the hypothetical
sorted stream of items presented to the sketch.
<p>Suppose the sketch is presented with N values. The raw rank (0 to N-1) of an item
would be its index position in the sorted version of the input stream. If we divide the
raw rank by N, it becomes the normalized rank, which is between 0 and 1.0.
<p>For example, choosing a K of 256 yields a normalized rank error of less than 1%.
The upper bound on the median value obtained by getQuantile(0.5) would be the value in the
hypothetical ordered stream of values at the normalized rank of 0.51.
The lower bound would be the value in the hypothetical ordered stream of values at the
normalized rank of 0.49.
<p>The error of this sketch cannot be translated into an error (relative or absolute) of the
returned quantile values.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the rank error normalized as a fraction between zero and one.</dd>
</dl>
</li>
</ul>
<a name="getNormalizedRankError-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getNormalizedRankError</h4>
<pre>public&nbsp;double&nbsp;getNormalizedRankError(boolean&nbsp;pmf)</pre>
<div class="block">Gets the approximate rank error of this sketch normalized as a fraction between zero and one.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>pmf</code> - if true, returns the "double-sided" normalized rank error for the getPMF() function.
Otherwise, it is the "single-sided" normalized rank error for all the other queries.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>if pmf is true, returns the normalized rank error for the getPMF() function.
Otherwise, it is the "single-sided" normalized rank error for all the other queries.</dd>
</dl>
</li>
</ul>
<a name="getNormalizedRankError-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getNormalizedRankError</h4>
<pre><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
public static&nbsp;double&nbsp;getNormalizedRankError(int&nbsp;k)</pre>
<div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;<span class="deprecationComment">replaced by <a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getNormalizedRankError-int-boolean-"><code>getNormalizedRankError(int, boolean)</code></a></span></div>
<div class="block">Static method version of <a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getNormalizedRankError--"><code>getNormalizedRankError()</code></a></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k</code> - the configuration parameter of a DoublesSketch</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the rank error normalized as a fraction between zero and one.</dd>
</dl>
</li>
</ul>
<a name="getNormalizedRankError-int-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getNormalizedRankError</h4>
<pre>public static&nbsp;double&nbsp;getNormalizedRankError(int&nbsp;k,
boolean&nbsp;pmf)</pre>
<div class="block">Gets the normalized rank error given k and pmf.
Static method version of the <a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html#getNormalizedRankError-boolean-"><code>getNormalizedRankError(boolean)</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k</code> - the configuation parameter</dd>
<dd><code>pmf</code> - if true, returns the "double-sided" normalized rank error for the getPMF() function.
Otherwise, it is the "single-sided" normalized rank error for all the other queries.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>if pmf is true, the normalized rank error for the getPMF() function.
Otherwise, it is the "single-sided" normalized rank error for all the other queries.</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../com/yahoo/sketches/kll/KllFloatsSketch.html" title="class in com.yahoo.sketches.kll"><code>KllFloatsSketch</code></a></dd>
</dl>
</li>
</ul>
<a name="getKFromEpsilon-double-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getKFromEpsilon</h4>
<pre>public static&nbsp;int&nbsp;getKFromEpsilon(double&nbsp;epsilon,
boolean&nbsp;pmf)</pre>
<div class="block">Gets the approximate value of <em>k</em> to use given epsilon, the normalized rank error.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>epsilon</code> - the normalized rank error between zero and one.</dd>
<dd><code>pmf</code> - if true, this function returns the value of <em>k</em> assuming the input epsilon
is the desired "double-sided" epsilon for the getPMF() function. Otherwise, this function
returns the value of <em>k</em> assuming the input epsilon is the desired "single-sided"
epsilon for all the other queries.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the value of <i>k</i> given a value of epsilon.</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../com/yahoo/sketches/kll/KllFloatsSketch.html" title="class in com.yahoo.sketches.kll"><code>KllFloatsSketch</code></a></dd>
</dl>
</li>
</ul>
<a name="isEmpty--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isEmpty</h4>
<pre>public&nbsp;boolean&nbsp;isEmpty()</pre>
<div class="block">Returns true if this sketch is empty</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if this sketch is empty</dd>
</dl>
</li>
</ul>
<a name="isDirect--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isDirect</h4>
<pre>public abstract&nbsp;boolean&nbsp;isDirect()</pre>
<div class="block">Returns true if this sketch is direct</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if this sketch is direct</dd>
</dl>
</li>
</ul>
<a name="isEstimationMode--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isEstimationMode</h4>
<pre>public&nbsp;boolean&nbsp;isEstimationMode()</pre>
<div class="block">Returns true if this sketch is in estimation mode.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if this sketch is in estimation mode.</dd>
</dl>
</li>
</ul>
<a name="isSameResource-com.yahoo.memory.Memory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isSameResource</h4>
<pre>public&nbsp;boolean&nbsp;isSameResource(com.yahoo.memory.Memory&nbsp;that)</pre>
<div class="block">Returns true if the backing resource of <i>this</i> is identical with the backing resource
of <i>that</i>. The capacities must be the same. If <i>this</i> is a region,
the region offset must also be the same.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>that</code> - A different non-null object</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if the backing resource of <i>this</i> is the same as the backing resource
of <i>that</i>.</dd>
</dl>
</li>
</ul>
<a name="toByteArray--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toByteArray</h4>
<pre>public&nbsp;byte[]&nbsp;toByteArray()</pre>
<div class="block">Serialize this sketch to a byte array. An UpdateDoublesSketch will be serialized in
an unordered, non-compact form; a CompactDoublesSketch will be serialized in ordered,
compact form. A DirectUpdateDoublesSketch can only wrap a non-compact array, and a
DirectCompactDoublesSketch can only wrap a compact array.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>byte array of this sketch</dd>
</dl>
</li>
</ul>
<a name="toByteArray-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toByteArray</h4>
<pre>public&nbsp;byte[]&nbsp;toByteArray(boolean&nbsp;compact)</pre>
<div class="block">Serialize this sketch in a byte array form.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>compact</code> - if true the sketch will be serialized in compact form.
DirectCompactDoublesSketch can wrap() only a compact byte array;
DirectUpdateDoublesSketch can wrap() only a non-compact byte array.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>this sketch in a byte array form.</dd>
</dl>
</li>
</ul>
<a name="toString--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;toString()</pre>
<div class="block">Returns summary information about this sketch.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a></code>&nbsp;in class&nbsp;<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></dd>
</dl>
</li>
</ul>
<a name="toString-boolean-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;toString(boolean&nbsp;sketchSummary,
boolean&nbsp;dataDetail)</pre>
<div class="block">Returns summary information about this sketch. Used for debugging.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>sketchSummary</code> - if true includes sketch summary</dd>
<dd><code>dataDetail</code> - if true includes data detail</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>summary information about the sketch.</dd>
</dl>
</li>
</ul>
<a name="downSample-com.yahoo.sketches.quantiles.DoublesSketch-int-com.yahoo.memory.WritableMemory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>downSample</h4>
<pre>public&nbsp;<a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html" title="class in com.yahoo.sketches.quantiles">DoublesSketch</a>&nbsp;downSample(<a href="../../../../com/yahoo/sketches/quantiles/DoublesSketch.html" title="class in com.yahoo.sketches.quantiles">DoublesSketch</a>&nbsp;srcSketch,
int&nbsp;smallerK,
com.yahoo.memory.WritableMemory&nbsp;dstMem)</pre>
<div class="block">From an source sketch, create a new sketch that must have a smaller value of K.
The original sketch is not modified.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>srcSketch</code> - the sourcing sketch</dd>
<dd><code>smallerK</code> - the new sketch's value of K that must be smaller than this value of K.
It is required that this.getK() = smallerK * 2^(nonnegative integer).</dd>
<dd><code>dstMem</code> - the destination Memory. It must not overlap the Memory of this sketch.
If null, a heap sketch will be returned, otherwise it will be off-heap.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new sketch.</dd>
</dl>
</li>
</ul>
<a name="getRetainedItems--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getRetainedItems</h4>
<pre>public&nbsp;int&nbsp;getRetainedItems()</pre>
<div class="block">Computes the number of retained items (samples) in the sketch</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the number of retained items (samples) in the sketch</dd>
</dl>
</li>
</ul>
<a name="getCompactStorageBytes--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCompactStorageBytes</h4>
<pre>public&nbsp;int&nbsp;getCompactStorageBytes()</pre>
<div class="block">Returns the number of bytes this sketch would require to store in compact form, which is not
updatable.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the number of bytes this sketch would require to store in compact form.</dd>
</dl>
</li>
</ul>
<a name="getCompactStorageBytes-int-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCompactStorageBytes</h4>
<pre>public static&nbsp;int&nbsp;getCompactStorageBytes(int&nbsp;k,
long&nbsp;n)</pre>
<div class="block">Returns the number of bytes a DoublesSketch would require to store in compact form
given the values of <i>k</i> and <i>n</i>. The compact form is not updatable.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k</code> - the size configuration parameter for the sketch</dd>
<dd><code>n</code> - the number of items input into the sketch</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the number of bytes required to store this sketch in compact form.</dd>
</dl>
</li>
</ul>
<a name="getStorageBytes--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getStorageBytes</h4>
<pre>public&nbsp;int&nbsp;getStorageBytes()</pre>
<div class="block">Returns the number of bytes this sketch would require to store in native form: compact for
a CompactDoublesSketch, non-compact for an UpdateDoublesSketch.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the number of bytes this sketch would require to store in compact form.</dd>
</dl>
</li>
</ul>
<a name="getUpdatableStorageBytes--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getUpdatableStorageBytes</h4>
<pre>public&nbsp;int&nbsp;getUpdatableStorageBytes()</pre>
<div class="block">Returns the number of bytes this sketch would require to store in updatable form.
This uses roughly 2X the storage of the compact form.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the number of bytes this sketch would require to store in updatable form.</dd>
</dl>
</li>
</ul>
<a name="getUpdatableStorageBytes-int-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getUpdatableStorageBytes</h4>
<pre>public static&nbsp;int&nbsp;getUpdatableStorageBytes(int&nbsp;k,
long&nbsp;n)</pre>
<div class="block">Returns the number of bytes a sketch would require to store in updatable form.
This uses roughly 2X the storage of the compact form
given the values of <i>k</i> and <i>n</i>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k</code> - the size configuration parameter for the sketch</dd>
<dd><code>n</code> - the number of items input into the sketch</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the number of bytes this sketch would require to store in updatable form.</dd>
</dl>
</li>
</ul>
<a name="putMemory-com.yahoo.memory.WritableMemory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>putMemory</h4>
<pre>public&nbsp;void&nbsp;putMemory(com.yahoo.memory.WritableMemory&nbsp;dstMem)</pre>
<div class="block">Puts the current sketch into the given Memory in compact form if there is sufficient space,
otherwise, it throws an error.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>dstMem</code> - the given memory.</dd>
</dl>
</li>
</ul>
<a name="putMemory-com.yahoo.memory.WritableMemory-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>putMemory</h4>
<pre>public&nbsp;void&nbsp;putMemory(com.yahoo.memory.WritableMemory&nbsp;dstMem,
boolean&nbsp;compact)</pre>
<div class="block">Puts the current sketch into the given Memory if there is sufficient space, otherwise,
throws an error.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>dstMem</code> - the given memory.</dd>
<dd><code>compact</code> - if true, compacts and sorts the base buffer, which optimizes merge
performance at the cost of slightly increased serialization time.</dd>
</dl>
</li>
</ul>
<a name="iterator--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>iterator</h4>
<pre>public&nbsp;<a href="../../../../com/yahoo/sketches/quantiles/DoublesSketchIterator.html" title="class in com.yahoo.sketches.quantiles">DoublesSketchIterator</a>&nbsp;iterator()</pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/DoublesSketch.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../com/yahoo/sketches/quantiles/CompactDoublesSketch.html" title="class in com.yahoo.sketches.quantiles"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../com/yahoo/sketches/quantiles/DoublesSketchBuilder.html" title="class in com.yahoo.sketches.quantiles"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?com/yahoo/sketches/quantiles/DoublesSketch.html" target="_top">Frames</a></li>
<li><a href="DoublesSketch.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2015&#x2013;2018. All rights reserved.</small></p>
</body>
</html>