blob: 207059383d62a84226d6c810a28ce1d73def2a2e [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>
<title>Variance</title>
<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="Variance";
}
}
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":9,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete 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="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="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/ThirdMoment.html" title="class in org.apache.openejb.math.stat.descriptive.moment"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li>Next&nbsp;Class</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../index.html?org/apache/openejb/math/stat/descriptive/moment/Variance.html" target="_top">Frames</a></li>
<li><a href="Variance.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><a href="#constructor.summary">Constr</a>&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><a href="#constructor.detail">Constr</a>&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">org.apache.openejb.math.stat.descriptive.moment</div>
<h2 title="Class Variance" class="title">Class Variance</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractUnivariateStatistic.html" title="class in org.apache.openejb.math.stat.descriptive">org.apache.openejb.math.stat.descriptive.AbstractUnivariateStatistic</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.openejb.math.stat.descriptive">org.apache.openejb.math.stat.descriptive.AbstractStorelessUnivariateStatistic</a></li>
<li>
<ul class="inheritance">
<li>org.apache.openejb.math.stat.descriptive.moment.Variance</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd>java.io.Serializable, <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.openejb.math.stat.descriptive">StorelessUnivariateStatistic</a>, <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/UnivariateStatistic.html" title="interface in org.apache.openejb.math.stat.descriptive">UnivariateStatistic</a>, <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/WeightedEvaluation.html" title="interface in org.apache.openejb.math.stat.descriptive">WeightedEvaluation</a></dd>
</dl>
<hr>
<br>
<pre>public class <span class="typeNameLabel">Variance</span>
extends <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.openejb.math.stat.descriptive">AbstractStorelessUnivariateStatistic</a>
implements java.io.Serializable, <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/WeightedEvaluation.html" title="interface in org.apache.openejb.math.stat.descriptive">WeightedEvaluation</a></pre>
<div class="block">Computes the variance of the available values. By default, the unbiased
"sample variance" definitional formula is used:
<p>
variance = sum((x_i - mean)^2) / (n - 1) </p>
<p>
where mean is the <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Mean.html" title="class in org.apache.openejb.math.stat.descriptive.moment"><code>Mean</code></a> and <code>n</code> is the number
of sample observations.</p>
<p>
The definitional formula does not have good numerical properties, so
this implementation does not compute the statistic using the definitional
formula. <ul>
<li> The <code>getResult</code> method computes the variance using
updating formulas based on West's algorithm, as described in
<a href="http://doi.acm.org/10.1145/359146.359152"> Chan, T. F. and
J. G. Lewis 1979, <i>Communications of the ACM</i>,
vol. 22 no. 9, pp. 526-531.</a></li>
<li> The <code>evaluate</code> methods leverage the fact that they have the
full array of values in memory to execute a two-pass algorithm.
Specifically, these methods use the "corrected two-pass algorithm" from
Chan, Golub, Levesque, <i>Algorithms for Computing the Sample Variance</i>,
American Statistician, vol. 37, no. 3 (1983) pp. 242-247.</li></ul>
Note that adding values using <code>increment</code> or
<code>incrementAll</code> and then executing <code>getResult</code> will
sometimes give a different, less accurate, result than executing
<code>evaluate</code> with the full array of values. The former approach
should only be used when the full array of values is not available.</p>
<p>
The "population variance" ( sum((x_i - mean)^2) / n ) can also
be computed using this statistic. The <code>isBiasCorrected</code>
property determines whether the "population" or "sample" value is
returned by the <code>evaluate</code> and <code>getResult</code> methods.
To compute population variances, set this property to <code>false.</code>
</p>
<p>
<strong>Note that this implementation is not synchronized.</strong> If
multiple threads access an instance of this class concurrently, and at least
one of the threads invokes the <code>increment()</code> or
<code>clear()</code> method, it must be synchronized externally.</p></div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../../../serialized-form.html#org.apache.openejb.math.stat.descriptive.moment.Variance">Serialized Form</a></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>protected boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#incMoment">incMoment</a></span></code>
<div class="block">Boolean test to determine if this Variance should also increment
the second moment, this evaluates to false when this Variance is
constructed with an external SecondMoment as a parameter.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>protected <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.openejb.math.stat.descriptive.moment">SecondMoment</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#moment">moment</a></span></code>
<div class="block">SecondMoment is used in incremental calculation of Variance</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#Variance--">Variance</a></span>()</code>
<div class="block">Constructs a Variance with default (true) <code>isBiasCorrected</code>
property.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#Variance-boolean-">Variance</a></span>(boolean&nbsp;isBiasCorrected)</code>
<div class="block">Constructs a Variance with the specified <code>isBiasCorrected</code>
property</div>
</td>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#Variance-boolean-org.apache.openejb.math.stat.descriptive.moment.SecondMoment-">Variance</a></span>(boolean&nbsp;isBiasCorrected,
<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.openejb.math.stat.descriptive.moment">SecondMoment</a>&nbsp;m2)</code>
<div class="block">Constructs a Variance with the specified <code>isBiasCorrected</code>
property and the supplied external second moment.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#Variance-org.apache.openejb.math.stat.descriptive.moment.SecondMoment-">Variance</a></span>(<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.openejb.math.stat.descriptive.moment">SecondMoment</a>&nbsp;m2)</code>
<div class="block">Constructs a Variance based on an external second moment.</div>
</td>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#Variance-org.apache.openejb.math.stat.descriptive.moment.Variance-">Variance</a></span>(<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment">Variance</a>&nbsp;original)</code>
<div class="block">Copy constructor, creates a new <code>Variance</code> identical
to the <code>original</code></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="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete 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>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#clear--">clear</a></span>()</code>
<div class="block">Clears the internal state of the Statistic</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment">Variance</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#copy--">copy</a></span>()</code>
<div class="block">Returns a copy of the statistic with the same internal state.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#copy-org.apache.openejb.math.stat.descriptive.moment.Variance-org.apache.openejb.math.stat.descriptive.moment.Variance-">copy</a></span>(<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment">Variance</a>&nbsp;source,
<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment">Variance</a>&nbsp;dest)</code>
<div class="block">Copies source to dest.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#evaluate-double:A-">evaluate</a></span>(double[]&nbsp;values)</code>
<div class="block">Returns the variance of the entries in the input array, or
<code>Double.NaN</code> if the array is empty.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#evaluate-double:A-double-">evaluate</a></span>(double[]&nbsp;values,
double&nbsp;mean)</code>
<div class="block">Returns the variance of the entries in the input array, using the
precomputed mean value.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#evaluate-double:A-double:A-">evaluate</a></span>(double[]&nbsp;values,
double[]&nbsp;weights)</code>
<div class="block">
Returns the weighted variance of the entries in the the input array.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#evaluate-double:A-double:A-double-">evaluate</a></span>(double[]&nbsp;values,
double[]&nbsp;weights,
double&nbsp;mean)</code>
<div class="block">Returns the weighted variance of the values in the input array, using
the precomputed weighted mean value.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#evaluate-double:A-double:A-double-int-int-">evaluate</a></span>(double[]&nbsp;values,
double[]&nbsp;weights,
double&nbsp;mean,
int&nbsp;begin,
int&nbsp;length)</code>
<div class="block">Returns the weighted variance of the entries in the specified portion of
the input array, using the precomputed weighted mean value.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#evaluate-double:A-double:A-int-int-">evaluate</a></span>(double[]&nbsp;values,
double[]&nbsp;weights,
int&nbsp;begin,
int&nbsp;length)</code>
<div class="block">Returns the weighted variance of the entries in the specified portion of
the input array, or <code>Double.NaN</code> if the designated subarray
is empty.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#evaluate-double:A-double-int-int-">evaluate</a></span>(double[]&nbsp;values,
double&nbsp;mean,
int&nbsp;begin,
int&nbsp;length)</code>
<div class="block">Returns the variance of the entries in the specified portion of
the input array, using the precomputed mean value.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#evaluate-double:A-int-int-">evaluate</a></span>(double[]&nbsp;values,
int&nbsp;begin,
int&nbsp;length)</code>
<div class="block">Returns the variance of the entries in the specified portion of
the input array, or <code>Double.NaN</code> if the designated subarray
is empty.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#getN--">getN</a></span>()</code>
<div class="block">Returns the number of values that have been added.</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#getResult--">getResult</a></span>()</code>
<div class="block">Returns the current value of the Statistic.</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#increment-double-">increment</a></span>(double&nbsp;d)</code>
<div class="block">Updates the internal state of the statistic to reflect the addition of the new value.</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#isBiasCorrected--">isBiasCorrected</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#setBiasCorrected-boolean-">setBiasCorrected</a></span>(boolean&nbsp;biasCorrected)</code>&nbsp;</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.org.apache.openejb.math.stat.descriptive.AbstractStorelessUnivariateStatistic">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;org.apache.openejb.math.stat.descriptive.<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.openejb.math.stat.descriptive">AbstractStorelessUnivariateStatistic</a></h3>
<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html#equals-java.lang.Object-">equals</a>, <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html#hashCode--">hashCode</a>, <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html#incrementAll-double:A-">incrementAll</a>, <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html#incrementAll-double:A-int-int-">incrementAll</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.org.apache.openejb.math.stat.descriptive.AbstractUnivariateStatistic">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;org.apache.openejb.math.stat.descriptive.<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractUnivariateStatistic.html" title="class in org.apache.openejb.math.stat.descriptive">AbstractUnivariateStatistic</a></h3>
<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractUnivariateStatistic.html#test-double:A-double:A-int-int-">test</a>, <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractUnivariateStatistic.html#test-double:A-int-int-">test</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait</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="moment">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>moment</h4>
<pre>protected&nbsp;<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.openejb.math.stat.descriptive.moment">SecondMoment</a> moment</pre>
<div class="block">SecondMoment is used in incremental calculation of Variance</div>
</li>
</ul>
<a name="incMoment">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>incMoment</h4>
<pre>protected&nbsp;boolean incMoment</pre>
<div class="block">Boolean test to determine if this Variance should also increment
the second moment, this evaluates to false when this Variance is
constructed with an external SecondMoment as a parameter.</div>
</li>
</ul>
</li>
</ul>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="Variance--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>Variance</h4>
<pre>public&nbsp;Variance()</pre>
<div class="block">Constructs a Variance with default (true) <code>isBiasCorrected</code>
property.</div>
</li>
</ul>
<a name="Variance-org.apache.openejb.math.stat.descriptive.moment.SecondMoment-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>Variance</h4>
<pre>public&nbsp;Variance(<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.openejb.math.stat.descriptive.moment">SecondMoment</a>&nbsp;m2)</pre>
<div class="block">Constructs a Variance based on an external second moment.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>m2</code> - the SecondMoment (Third or Fourth moments work
here as well.)</dd>
</dl>
</li>
</ul>
<a name="Variance-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>Variance</h4>
<pre>public&nbsp;Variance(boolean&nbsp;isBiasCorrected)</pre>
<div class="block">Constructs a Variance with the specified <code>isBiasCorrected</code>
property</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>isBiasCorrected</code> - setting for bias correction - true means
bias will be corrected and is equivalent to using the argumentless
constructor</dd>
</dl>
</li>
</ul>
<a name="Variance-boolean-org.apache.openejb.math.stat.descriptive.moment.SecondMoment-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>Variance</h4>
<pre>public&nbsp;Variance(boolean&nbsp;isBiasCorrected,
<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.openejb.math.stat.descriptive.moment">SecondMoment</a>&nbsp;m2)</pre>
<div class="block">Constructs a Variance with the specified <code>isBiasCorrected</code>
property and the supplied external second moment.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>isBiasCorrected</code> - setting for bias correction - true means
bias will be corrected</dd>
<dd><code>m2</code> - the SecondMoment (Third or Fourth moments work
here as well.)</dd>
</dl>
</li>
</ul>
<a name="Variance-org.apache.openejb.math.stat.descriptive.moment.Variance-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>Variance</h4>
<pre>public&nbsp;Variance(<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment">Variance</a>&nbsp;original)</pre>
<div class="block">Copy constructor, creates a new <code>Variance</code> identical
to the <code>original</code></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>original</code> - the <code>Variance</code> instance to copy</dd>
</dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="increment-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>increment</h4>
<pre>public&nbsp;void&nbsp;increment(double&nbsp;d)</pre>
<div class="block">Updates the internal state of the statistic to reflect the addition of the new value.
<p>If all values are available, it is more accurate to use
<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#evaluate-double:A-"><code>evaluate(double[])</code></a> rather than adding values one at a time
using this method and then executing <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html#getResult--"><code>getResult()</code></a>, since
<code>evaluate</code> leverages the fact that is has the full
list of values together to execute a two-pass algorithm.
See <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment"><code>Variance</code></a>.</p></div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.html#increment-double-">increment</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.openejb.math.stat.descriptive">StorelessUnivariateStatistic</a></code></dd>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html#increment-double-">increment</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.openejb.math.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>d</code> - the new value.</dd>
</dl>
</li>
</ul>
<a name="getResult--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getResult</h4>
<pre>public&nbsp;double&nbsp;getResult()</pre>
<div class="block">Returns the current value of the Statistic.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.html#getResult--">getResult</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.openejb.math.stat.descriptive">StorelessUnivariateStatistic</a></code></dd>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html#getResult--">getResult</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.openejb.math.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>value of the statistic, <code>Double.NaN</code> if it
has been cleared or just instantiated.</dd>
</dl>
</li>
</ul>
<a name="getN--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getN</h4>
<pre>public&nbsp;long&nbsp;getN()</pre>
<div class="block">Returns the number of values that have been added.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.html#getN--">getN</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.openejb.math.stat.descriptive">StorelessUnivariateStatistic</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the number of values.</dd>
</dl>
</li>
</ul>
<a name="clear--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>clear</h4>
<pre>public&nbsp;void&nbsp;clear()</pre>
<div class="block">Clears the internal state of the Statistic</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.html#clear--">clear</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.openejb.math.stat.descriptive">StorelessUnivariateStatistic</a></code></dd>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html#clear--">clear</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.openejb.math.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd>
</dl>
</li>
</ul>
<a name="evaluate-double:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>evaluate</h4>
<pre>public&nbsp;double&nbsp;evaluate(double[]&nbsp;values)</pre>
<div class="block">Returns the variance of the entries in the input array, or
<code>Double.NaN</code> if the array is empty.
<p>
See <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment"><code>Variance</code></a> for details on the computing algorithm.</p>
<p>
Returns 0 for a single-value (i.e. length = 1) sample.</p>
<p>
Throws <code>IllegalArgumentException</code> if the array is null.</p>
<p>
Does not change the internal state of the statistic.</p></div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/UnivariateStatistic.html#evaluate-double:A-">evaluate</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/UnivariateStatistic.html" title="interface in org.apache.openejb.math.stat.descriptive">UnivariateStatistic</a></code></dd>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html#evaluate-double:A-">evaluate</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.openejb.math.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>values</code> - the input array</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the variance of the values or Double.NaN if length = 0</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the array is null</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/UnivariateStatistic.html#evaluate-double:A-"><code>UnivariateStatistic.evaluate(double[])</code></a></dd>
</dl>
</li>
</ul>
<a name="evaluate-double:A-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>evaluate</h4>
<pre>public&nbsp;double&nbsp;evaluate(double[]&nbsp;values,
int&nbsp;begin,
int&nbsp;length)</pre>
<div class="block">Returns the variance of the entries in the specified portion of
the input array, or <code>Double.NaN</code> if the designated subarray
is empty.
<p>
See <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment"><code>Variance</code></a> for details on the computing algorithm.</p>
<p>
Returns 0 for a single-value (i.e. length = 1) sample.</p>
<p>
Does not change the internal state of the statistic.</p>
<p>
Throws <code>IllegalArgumentException</code> if the array is null.</p></div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/UnivariateStatistic.html#evaluate-double:A-int-int-">evaluate</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/UnivariateStatistic.html" title="interface in org.apache.openejb.math.stat.descriptive">UnivariateStatistic</a></code></dd>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html#evaluate-double:A-int-int-">evaluate</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.openejb.math.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>values</code> - the input array</dd>
<dd><code>begin</code> - index of the first array element to include</dd>
<dd><code>length</code> - the number of elements to include</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the variance of the values or Double.NaN if length = 0</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the array is null or the array index
parameters are not valid</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/UnivariateStatistic.html#evaluate-double:A-int-int-"><code>UnivariateStatistic.evaluate(double[], int, int)</code></a></dd>
</dl>
</li>
</ul>
<a name="evaluate-double:A-double:A-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>evaluate</h4>
<pre>public&nbsp;double&nbsp;evaluate(double[]&nbsp;values,
double[]&nbsp;weights,
int&nbsp;begin,
int&nbsp;length)</pre>
<div class="block"><p>Returns the weighted variance of the entries in the specified portion of
the input array, or <code>Double.NaN</code> if the designated subarray
is empty.</p>
<p>
Uses the formula <pre>
&Sigma;(weights[i]*(values[i] - weightedMean)<sup>2</sup>)/(&Sigma;(weights[i]) - 1)
</pre>
where weightedMean is the weighted mean</p>
<p>
This formula will not return the same result as the unweighted variance when all
weights are equal, unless all weights are equal to 1. The formula assumes that
weights are to be treated as "expansion values," as will be the case if for example
the weights represent frequency counts. To normalize weights so that the denominator
in the variance computation equals the length of the input vector minus one, use <pre>
<code>evaluate(values, MathUtils.normalizeArray(weights, values.length)); </code>
</pre>
<p>
Returns 0 for a single-value (i.e. length = 1) sample.</p>
<p>
Throws <code>IllegalArgumentException</code> if any of the following are true:
<ul><li>the values array is null</li>
<li>the weights array is null</li>
<li>the weights array does not have the same length as the values array</li>
<li>the weights array contains one or more infinite values</li>
<li>the weights array contains one or more NaN values</li>
<li>the weights array contains negative values</li>
<li>the start and length arguments do not determine a valid array</li>
</ul></p>
<p>
Does not change the internal state of the statistic.</p>
<p>
Throws <code>IllegalArgumentException</code> if either array is null.</p></div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/WeightedEvaluation.html#evaluate-double:A-double:A-int-int-">evaluate</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/WeightedEvaluation.html" title="interface in org.apache.openejb.math.stat.descriptive">WeightedEvaluation</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>values</code> - the input array</dd>
<dd><code>weights</code> - the weights array</dd>
<dd><code>begin</code> - index of the first array element to include</dd>
<dd><code>length</code> - the number of elements to include</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the weighted variance of the values or Double.NaN if length = 0</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the parameters are not valid</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.1</dd>
</dl>
</li>
</ul>
<a name="evaluate-double:A-double:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>evaluate</h4>
<pre>public&nbsp;double&nbsp;evaluate(double[]&nbsp;values,
double[]&nbsp;weights)</pre>
<div class="block"><p>
Returns the weighted variance of the entries in the the input array.</p>
<p>
Uses the formula <pre>
&Sigma;(weights[i]*(values[i] - weightedMean)<sup>2</sup>)/(&Sigma;(weights[i]) - 1)
</pre>
where weightedMean is the weighted mean</p>
<p>
This formula will not return the same result as the unweighted variance when all
weights are equal, unless all weights are equal to 1. The formula assumes that
weights are to be treated as "expansion values," as will be the case if for example
the weights represent frequency counts. To normalize weights so that the denominator
in the variance computation equals the length of the input vector minus one, use <pre>
<code>evaluate(values, MathUtils.normalizeArray(weights, values.length)); </code>
</pre>
<p>
Returns 0 for a single-value (i.e. length = 1) sample.</p>
<p>
Throws <code>IllegalArgumentException</code> if any of the following are true:
<ul><li>the values array is null</li>
<li>the weights array is null</li>
<li>the weights array does not have the same length as the values array</li>
<li>the weights array contains one or more infinite values</li>
<li>the weights array contains one or more NaN values</li>
<li>the weights array contains negative values</li>
</ul></p>
<p>
Does not change the internal state of the statistic.</p>
<p>
Throws <code>IllegalArgumentException</code> if either array is null.</p></div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/WeightedEvaluation.html#evaluate-double:A-double:A-">evaluate</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/WeightedEvaluation.html" title="interface in org.apache.openejb.math.stat.descriptive">WeightedEvaluation</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>values</code> - the input array</dd>
<dd><code>weights</code> - the weights array</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the weighted variance of the values</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the parameters are not valid</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.1</dd>
</dl>
</li>
</ul>
<a name="evaluate-double:A-double-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>evaluate</h4>
<pre>public&nbsp;double&nbsp;evaluate(double[]&nbsp;values,
double&nbsp;mean,
int&nbsp;begin,
int&nbsp;length)</pre>
<div class="block">Returns the variance of the entries in the specified portion of
the input array, using the precomputed mean value. Returns
<code>Double.NaN</code> if the designated subarray is empty.
<p>
See <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment"><code>Variance</code></a> for details on the computing algorithm.</p>
<p>
The formula used assumes that the supplied mean value is the arithmetic
mean of the sample data, not a known population parameter. This method
is supplied only to save computation when the mean has already been
computed.</p>
<p>
Returns 0 for a single-value (i.e. length = 1) sample.</p>
<p>
Throws <code>IllegalArgumentException</code> if the array is null.</p>
<p>
Does not change the internal state of the statistic.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>values</code> - the input array</dd>
<dd><code>mean</code> - the precomputed mean value</dd>
<dd><code>begin</code> - index of the first array element to include</dd>
<dd><code>length</code> - the number of elements to include</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the variance of the values or Double.NaN if length = 0</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the array is null or the array index
parameters are not valid</dd>
</dl>
</li>
</ul>
<a name="evaluate-double:A-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>evaluate</h4>
<pre>public&nbsp;double&nbsp;evaluate(double[]&nbsp;values,
double&nbsp;mean)</pre>
<div class="block">Returns the variance of the entries in the input array, using the
precomputed mean value. Returns <code>Double.NaN</code> if the array
is empty.
<p>
See <a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment"><code>Variance</code></a> for details on the computing algorithm.</p>
<p>
If <code>isBiasCorrected</code> is <code>true</code> the formula used
assumes that the supplied mean value is the arithmetic mean of the
sample data, not a known population parameter. If the mean is a known
population parameter, or if the "population" version of the variance is
desired, set <code>isBiasCorrected</code> to <code>false</code> before
invoking this method.</p>
<p>
Returns 0 for a single-value (i.e. length = 1) sample.</p>
<p>
Throws <code>IllegalArgumentException</code> if the array is null.</p>
<p>
Does not change the internal state of the statistic.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>values</code> - the input array</dd>
<dd><code>mean</code> - the precomputed mean value</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the variance of the values or Double.NaN if the array is empty</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the array is null</dd>
</dl>
</li>
</ul>
<a name="evaluate-double:A-double:A-double-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>evaluate</h4>
<pre>public&nbsp;double&nbsp;evaluate(double[]&nbsp;values,
double[]&nbsp;weights,
double&nbsp;mean,
int&nbsp;begin,
int&nbsp;length)</pre>
<div class="block">Returns the weighted variance of the entries in the specified portion of
the input array, using the precomputed weighted mean value. Returns
<code>Double.NaN</code> if the designated subarray is empty.
<p>
Uses the formula <pre>
&Sigma;(weights[i]*(values[i] - mean)<sup>2</sup>)/(&Sigma;(weights[i]) - 1)
</pre></p>
<p>
The formula used assumes that the supplied mean value is the weighted arithmetic
mean of the sample data, not a known population parameter. This method
is supplied only to save computation when the mean has already been
computed.</p>
<p>
This formula will not return the same result as the unweighted variance when all
weights are equal, unless all weights are equal to 1. The formula assumes that
weights are to be treated as "expansion values," as will be the case if for example
the weights represent frequency counts. To normalize weights so that the denominator
in the variance computation equals the length of the input vector minus one, use <pre>
<code>evaluate(values, MathUtils.normalizeArray(weights, values.length), mean); </code>
</pre>
<p>
Returns 0 for a single-value (i.e. length = 1) sample.</p>
<p>
Throws <code>IllegalArgumentException</code> if any of the following are true:
<ul><li>the values array is null</li>
<li>the weights array is null</li>
<li>the weights array does not have the same length as the values array</li>
<li>the weights array contains one or more infinite values</li>
<li>the weights array contains one or more NaN values</li>
<li>the weights array contains negative values</li>
<li>the start and length arguments do not determine a valid array</li>
</ul></p>
<p>
Does not change the internal state of the statistic.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>values</code> - the input array</dd>
<dd><code>weights</code> - the weights array</dd>
<dd><code>mean</code> - the precomputed weighted mean value</dd>
<dd><code>begin</code> - index of the first array element to include</dd>
<dd><code>length</code> - the number of elements to include</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the variance of the values or Double.NaN if length = 0</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the parameters are not valid</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.1</dd>
</dl>
</li>
</ul>
<a name="evaluate-double:A-double:A-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>evaluate</h4>
<pre>public&nbsp;double&nbsp;evaluate(double[]&nbsp;values,
double[]&nbsp;weights,
double&nbsp;mean)</pre>
<div class="block"><p>Returns the weighted variance of the values in the input array, using
the precomputed weighted mean value.</p>
<p>
Uses the formula <pre>
&Sigma;(weights[i]*(values[i] - mean)<sup>2</sup>)/(&Sigma;(weights[i]) - 1)
</pre></p>
<p>
The formula used assumes that the supplied mean value is the weighted arithmetic
mean of the sample data, not a known population parameter. This method
is supplied only to save computation when the mean has already been
computed.</p>
<p>
This formula will not return the same result as the unweighted variance when all
weights are equal, unless all weights are equal to 1. The formula assumes that
weights are to be treated as "expansion values," as will be the case if for example
the weights represent frequency counts. To normalize weights so that the denominator
in the variance computation equals the length of the input vector minus one, use <pre>
<code>evaluate(values, MathUtils.normalizeArray(weights, values.length), mean); </code>
</pre>
<p>
Returns 0 for a single-value (i.e. length = 1) sample.</p>
<p>
Throws <code>IllegalArgumentException</code> if any of the following are true:
<ul><li>the values array is null</li>
<li>the weights array is null</li>
<li>the weights array does not have the same length as the values array</li>
<li>the weights array contains one or more infinite values</li>
<li>the weights array contains one or more NaN values</li>
<li>the weights array contains negative values</li>
</ul></p>
<p>
Does not change the internal state of the statistic.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>values</code> - the input array</dd>
<dd><code>weights</code> - the weights array</dd>
<dd><code>mean</code> - the precomputed weighted mean value</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the variance of the values or Double.NaN if length = 0</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the parameters are not valid</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.1</dd>
</dl>
</li>
</ul>
<a name="isBiasCorrected--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isBiasCorrected</h4>
<pre>public&nbsp;boolean&nbsp;isBiasCorrected()</pre>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Returns the isBiasCorrected.</dd>
</dl>
</li>
</ul>
<a name="setBiasCorrected-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setBiasCorrected</h4>
<pre>public&nbsp;void&nbsp;setBiasCorrected(boolean&nbsp;biasCorrected)</pre>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>biasCorrected</code> - The isBiasCorrected to set.</dd>
</dl>
</li>
</ul>
<a name="copy--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>copy</h4>
<pre>public&nbsp;<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment">Variance</a>&nbsp;copy()</pre>
<div class="block">Returns a copy of the statistic with the same internal state.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.html#copy--">copy</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.openejb.math.stat.descriptive">StorelessUnivariateStatistic</a></code></dd>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/UnivariateStatistic.html#copy--">copy</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/UnivariateStatistic.html" title="interface in org.apache.openejb.math.stat.descriptive">UnivariateStatistic</a></code></dd>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html#copy--">copy</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../../org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.openejb.math.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a copy of the statistic</dd>
</dl>
</li>
</ul>
<a name="copy-org.apache.openejb.math.stat.descriptive.moment.Variance-org.apache.openejb.math.stat.descriptive.moment.Variance-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>copy</h4>
<pre>public static&nbsp;void&nbsp;copy(<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment">Variance</a>&nbsp;source,
<a href="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/Variance.html" title="class in org.apache.openejb.math.stat.descriptive.moment">Variance</a>&nbsp;dest)</pre>
<div class="block">Copies source to dest.
<p>Neither source nor dest can be null.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>source</code> - Variance to copy</dd>
<dd><code>dest</code> - Variance to copy to</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.NullPointerException</code> - if either source or dest is null</dd>
</dl>
</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="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="../../../../../../../org/apache/openejb/math/stat/descriptive/moment/ThirdMoment.html" title="class in org.apache.openejb.math.stat.descriptive.moment"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li>Next&nbsp;Class</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../index.html?org/apache/openejb/math/stat/descriptive/moment/Variance.html" target="_top">Frames</a></li>
<li><a href="Variance.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><a href="#constructor.summary">Constr</a>&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><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>