| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> |
| <title>Variance (Apache Commons Math 3.3 API)</title> |
| <link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style"> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="Variance (Apache Commons Math 3.3 API)"; |
| } |
| //--> |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar_top"> |
| <!-- --> |
| </a><a href="#skip-navbar_top" title="Skip navigation links"></a><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/Variance.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 class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/StandardDeviation.html" title="class in org.apache.commons.math3.stat.descriptive.moment"><span class="strong">Prev Class</span></a></li> |
| <li><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/VectorialCovariance.html" title="class in org.apache.commons.math3.stat.descriptive.moment"><span class="strong">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../../../index.html?org/apache/commons/math3/stat/descriptive/moment/Variance.html" target="_top">Frames</a></li> |
| <li><a href="Variance.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../../../../allclasses-noframe.html">All 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: </li> |
| <li>Nested | </li> |
| <li><a href="#field_summary">Field</a> | </li> |
| <li><a href="#constructor_summary">Constr</a> | </li> |
| <li><a href="#method_summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li><a href="#field_detail">Field</a> | </li> |
| <li><a href="#constructor_detail">Constr</a> | </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.commons.math3.stat.descriptive.moment</div> |
| <h2 title="Class Variance" class="title">Class Variance</h2> |
| </div> |
| <div class="contentContainer"> |
| <ul class="inheritance"> |
| <li><a href="http://docs.oracle.com/javase/6/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><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.html" title="class in org.apache.commons.math3.stat.descriptive">org.apache.commons.math3.stat.descriptive.AbstractUnivariateStatistic</a></li> |
| <li> |
| <ul class="inheritance"> |
| <li><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.commons.math3.stat.descriptive">org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic</a></li> |
| <li> |
| <ul class="inheritance"> |
| <li>org.apache.commons.math3.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><a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.commons.math3.stat.descriptive">StorelessUnivariateStatistic</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/UnivariateStatistic.html" title="interface in org.apache.commons.math3.stat.descriptive">UnivariateStatistic</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/WeightedEvaluation.html" title="interface in org.apache.commons.math3.stat.descriptive">WeightedEvaluation</a>, <a href="../../../../../../../org/apache/commons/math3/util/MathArrays.Function.html" title="interface in org.apache.commons.math3.util">MathArrays.Function</a></dd> |
| </dl> |
| <hr> |
| <br> |
| <pre>public class <span class="strong">Variance</span> |
| extends <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.commons.math3.stat.descriptive">AbstractStorelessUnivariateStatistic</a> |
| implements <a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/WeightedEvaluation.html" title="interface in org.apache.commons.math3.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/commons/math3/stat/descriptive/moment/Mean.html" title="class in org.apache.commons.math3.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="strong">Version:</span></dt> |
| <dd>$Id: Variance.java 1416643 2012-12-03 19:37:14Z tn $</dd> |
| <dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../../serialized-form.html#org.apache.commons.math3.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="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation"> |
| <caption><span>Fields</span><span class="tabEnd"> </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><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#incMoment">incMoment</a></strong></code> |
| <div class="block">Whether or not <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#increment(double)"><code>increment(double)</code></a> should increment |
| the internal second moment.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>protected <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.commons.math3.stat.descriptive.moment">SecondMoment</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#moment">moment</a></strong></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="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> |
| <caption><span>Constructors</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colOne" scope="col">Constructor and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colOne"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#Variance()">Variance</a></strong>()</code> |
| <div class="block">Constructs a Variance with default (true) <code>isBiasCorrected</code> |
| property.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colOne"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#Variance(boolean)">Variance</a></strong>(boolean 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><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#Variance(boolean, org.apache.commons.math3.stat.descriptive.moment.SecondMoment)">Variance</a></strong>(boolean isBiasCorrected, |
| <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.commons.math3.stat.descriptive.moment">SecondMoment</a> 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><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#Variance(org.apache.commons.math3.stat.descriptive.moment.SecondMoment)">Variance</a></strong>(<a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.commons.math3.stat.descriptive.moment">SecondMoment</a> m2)</code> |
| <div class="block">Constructs a Variance based on an external second moment.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colOne"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#Variance(org.apache.commons.math3.stat.descriptive.moment.Variance)">Variance</a></strong>(<a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.stat.descriptive.moment">Variance</a> 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="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> |
| <caption><span>Methods</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Method and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#clear()">clear</a></strong>()</code> |
| <div class="block">Clears the internal state of the Statistic</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.stat.descriptive.moment">Variance</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#copy()">copy</a></strong>()</code> |
| <div class="block">Returns a copy of the statistic with the same internal state.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#copy(org.apache.commons.math3.stat.descriptive.moment.Variance, org.apache.commons.math3.stat.descriptive.moment.Variance)">copy</a></strong>(<a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.stat.descriptive.moment">Variance</a> source, |
| <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.stat.descriptive.moment">Variance</a> dest)</code> |
| <div class="block">Copies source to dest.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#evaluate(double[])">evaluate</a></strong>(double[] 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 class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#evaluate(double[], double)">evaluate</a></strong>(double[] values, |
| double mean)</code> |
| <div class="block">Returns the variance of the entries in the input array, using the |
| precomputed mean value.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#evaluate(double[], double[])">evaluate</a></strong>(double[] values, |
| double[] weights)</code> |
| <div class="block"> |
| Returns the weighted variance of the entries in the the input array.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#evaluate(double[], double[], double)">evaluate</a></strong>(double[] values, |
| double[] weights, |
| double 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 class="rowColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#evaluate(double[], double[], double, int, int)">evaluate</a></strong>(double[] values, |
| double[] weights, |
| double mean, |
| int begin, |
| int 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 class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#evaluate(double[], double[], int, int)">evaluate</a></strong>(double[] values, |
| double[] weights, |
| int begin, |
| int 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 class="rowColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#evaluate(double[], double, int, int)">evaluate</a></strong>(double[] values, |
| double mean, |
| int begin, |
| int 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 class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#evaluate(double[], int, int)">evaluate</a></strong>(double[] values, |
| int begin, |
| int 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 class="rowColor"> |
| <td class="colFirst"><code>long</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#getN()">getN</a></strong>()</code> |
| <div class="block">Returns the number of values that have been added.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#getResult()">getResult</a></strong>()</code> |
| <div class="block">Returns the current value of the Statistic.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#increment(double)">increment</a></strong>(double d)</code> |
| <div class="block">Updates the internal state of the statistic to reflect the addition of the new value.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>boolean</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#isBiasCorrected()">isBiasCorrected</a></strong>()</code> </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>void</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#setBiasCorrected(boolean)">setBiasCorrected</a></strong>(boolean biasCorrected)</code> </td> |
| </tr> |
| </table> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods_inherited_from_class_org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class org.apache.commons.math3.stat.descriptive.<a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.commons.math3.stat.descriptive">AbstractStorelessUnivariateStatistic</a></h3> |
| <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html#equals(java.lang.Object)">equals</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html#hashCode()">hashCode</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html#incrementAll(double[])">incrementAll</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html#incrementAll(double[], int, int)">incrementAll</a></code></li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods_inherited_from_class_org.apache.commons.math3.stat.descriptive.AbstractUnivariateStatistic"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class org.apache.commons.math3.stat.descriptive.<a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.html" title="class in org.apache.commons.math3.stat.descriptive">AbstractUnivariateStatistic</a></h3> |
| <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.html#evaluate()">evaluate</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.html#getData()">getData</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.html#getDataRef()">getDataRef</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.html#setData(double[])">setData</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.html#setData(double[], int, int)">setData</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.html#test(double[], double[], int, int)">test</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.html#test(double[], double[], int, int, boolean)">test</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.html#test(double[], int, int)">test</a>, <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.html#test(double[], int, int, boolean)">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 java.lang.<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3> |
| <code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/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="moment"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>moment</h4> |
| <pre>protected <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.commons.math3.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 boolean incMoment</pre> |
| <div class="block">Whether or not <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#increment(double)"><code>increment(double)</code></a> should increment |
| the internal second moment. When a Variance is constructed with an |
| external SecondMoment as a constructor parameter, this property is |
| set to false and increments must be applied to the second moment |
| directly.</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 Variance()</pre> |
| <div class="block">Constructs a Variance with default (true) <code>isBiasCorrected</code> |
| property.</div> |
| </li> |
| </ul> |
| <a name="Variance(org.apache.commons.math3.stat.descriptive.moment.SecondMoment)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>Variance</h4> |
| <pre>public Variance(<a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.commons.math3.stat.descriptive.moment">SecondMoment</a> m2)</pre> |
| <div class="block">Constructs a Variance based on an external second moment. |
| When this constructor is used, the statistic may only be |
| incremented via the moment, i.e., <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#increment(double)"><code>increment(double)</code></a> |
| does nothing; whereas <code>m2.increment(value)</code> increments |
| both <code>m2</code> and the Variance instance constructed from it.</div> |
| <dl><dt><span class="strong">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 Variance(boolean isBiasCorrected)</pre> |
| <div class="block">Constructs a Variance with the specified <code>isBiasCorrected</code> |
| property</div> |
| <dl><dt><span class="strong">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.commons.math3.stat.descriptive.moment.SecondMoment)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>Variance</h4> |
| <pre>public Variance(boolean isBiasCorrected, |
| <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/SecondMoment.html" title="class in org.apache.commons.math3.stat.descriptive.moment">SecondMoment</a> 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="strong">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.commons.math3.stat.descriptive.moment.Variance)"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>Variance</h4> |
| <pre>public Variance(<a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.stat.descriptive.moment">Variance</a> original) |
| throws <a href="../../../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></pre> |
| <div class="block">Copy constructor, creates a new <code>Variance</code> identical |
| to the <code>original</code></div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>original</code> - the <code>Variance</code> instance to copy</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></code> - if original is null</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 void increment(double 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/commons/math3/stat/descriptive/moment/Variance.html#evaluate(double[])"><code>evaluate(double[])</code></a> rather than adding values one at a time |
| using this method and then executing <a href="../../../../../../../org/apache/commons/math3/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/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.stat.descriptive.moment"><code>Variance</code></a>.</p> |
| |
| <p>Note also that when <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html#Variance(org.apache.commons.math3.stat.descriptive.moment.SecondMoment)"><code>Variance(SecondMoment)</code></a> is used to |
| create a Variance, this method does nothing. In that case, the |
| SecondMoment should be incremented directly.</p></div> |
| <dl> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.html#increment(double)">increment</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.commons.math3.stat.descriptive">StorelessUnivariateStatistic</a></code></dd> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html#increment(double)">increment</a></code> in class <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.commons.math3.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd> |
| <dt><span class="strong">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 double getResult()</pre> |
| <div class="block">Returns the current value of the Statistic.</div> |
| <dl> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.html#getResult()">getResult</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.commons.math3.stat.descriptive">StorelessUnivariateStatistic</a></code></dd> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html#getResult()">getResult</a></code> in class <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.commons.math3.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd> |
| <dt><span class="strong">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 long getN()</pre> |
| <div class="block">Returns the number of values that have been added.</div> |
| <dl> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.html#getN()">getN</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.commons.math3.stat.descriptive">StorelessUnivariateStatistic</a></code></dd> |
| <dt><span class="strong">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 void clear()</pre> |
| <div class="block">Clears the internal state of the Statistic</div> |
| <dl> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.html#clear()">clear</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.commons.math3.stat.descriptive">StorelessUnivariateStatistic</a></code></dd> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html#clear()">clear</a></code> in class <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.commons.math3.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="evaluate(double[])"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>evaluate</h4> |
| <pre>public double evaluate(double[] values) |
| throws <a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></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/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.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>MathIllegalArgumentException</code> if the array is null.</p> |
| <p> |
| Does not change the internal state of the statistic.</p></div> |
| <dl> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/UnivariateStatistic.html#evaluate(double[])">evaluate</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/UnivariateStatistic.html" title="interface in org.apache.commons.math3.stat.descriptive">UnivariateStatistic</a></code></dd> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/util/MathArrays.Function.html#evaluate(double[])">evaluate</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/util/MathArrays.Function.html" title="interface in org.apache.commons.math3.util">MathArrays.Function</a></code></dd> |
| <dt><strong>Overrides:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html#evaluate(double[])">evaluate</a></code> in class <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.commons.math3.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd> |
| <dt><span class="strong">Parameters:</span></dt><dd><code>values</code> - the input array</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>the variance of the values or Double.NaN if length = 0</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></code> - if the array is null</dd><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/UnivariateStatistic.html#evaluate(double[])"><code>UnivariateStatistic.evaluate(double[])</code></a></dd></dl> |
| </li> |
| </ul> |
| <a name="evaluate(double[], int, int)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>evaluate</h4> |
| <pre>public double evaluate(double[] values, |
| int begin, |
| int length) |
| throws <a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></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/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.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>MathIllegalArgumentException</code> if the array is null.</p></div> |
| <dl> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/UnivariateStatistic.html#evaluate(double[], int, int)">evaluate</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/UnivariateStatistic.html" title="interface in org.apache.commons.math3.stat.descriptive">UnivariateStatistic</a></code></dd> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/util/MathArrays.Function.html#evaluate(double[], int, int)">evaluate</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/util/MathArrays.Function.html" title="interface in org.apache.commons.math3.util">MathArrays.Function</a></code></dd> |
| <dt><strong>Overrides:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html#evaluate(double[], int, int)">evaluate</a></code> in class <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.commons.math3.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd> |
| <dt><span class="strong">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="strong">Returns:</span></dt><dd>the variance of the values or Double.NaN if length = 0</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></code> - if the array is null or the array index |
| parameters are not valid</dd><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/UnivariateStatistic.html#evaluate(double[], int, int)"><code>UnivariateStatistic.evaluate(double[], int, int)</code></a></dd></dl> |
| </li> |
| </ul> |
| <a name="evaluate(double[], double[], int, int)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>evaluate</h4> |
| <pre>public double evaluate(double[] values, |
| double[] weights, |
| int begin, |
| int length) |
| throws <a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></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> |
| Σ(weights[i]*(values[i] - weightedMean)<sup>2</sup>)/(Σ(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, MathArrays.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>MathIllegalArgumentException</code> if either array is null.</p></div> |
| <dl> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/WeightedEvaluation.html#evaluate(double[], double[], int, int)">evaluate</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/WeightedEvaluation.html" title="interface in org.apache.commons.math3.stat.descriptive">WeightedEvaluation</a></code></dd> |
| <dt><span class="strong">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="strong">Returns:</span></dt><dd>the weighted variance of the values or Double.NaN if length = 0</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></code> - if the parameters are not valid</dd><dt><span class="strong">Since:</span></dt> |
| <dd>2.1</dd></dl> |
| </li> |
| </ul> |
| <a name="evaluate(double[], double[])"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>evaluate</h4> |
| <pre>public double evaluate(double[] values, |
| double[] weights) |
| throws <a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></pre> |
| <div class="block"><p> |
| Returns the weighted variance of the entries in the the input array.</p> |
| <p> |
| Uses the formula <pre> |
| Σ(weights[i]*(values[i] - weightedMean)<sup>2</sup>)/(Σ(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, MathArrays.normalizeArray(weights, values.length)); </code> |
| </pre> |
| <p> |
| Returns 0 for a single-value (i.e. length = 1) sample.</p> |
| <p> |
| Throws <code>MathIllegalArgumentException</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>MathIllegalArgumentException</code> if either array is null.</p></div> |
| <dl> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/WeightedEvaluation.html#evaluate(double[], double[])">evaluate</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/WeightedEvaluation.html" title="interface in org.apache.commons.math3.stat.descriptive">WeightedEvaluation</a></code></dd> |
| <dt><span class="strong">Parameters:</span></dt><dd><code>values</code> - the input array</dd><dd><code>weights</code> - the weights array</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>the weighted variance of the values</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></code> - if the parameters are not valid</dd><dt><span class="strong">Since:</span></dt> |
| <dd>2.1</dd></dl> |
| </li> |
| </ul> |
| <a name="evaluate(double[], double, int, int)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>evaluate</h4> |
| <pre>public double evaluate(double[] values, |
| double mean, |
| int begin, |
| int length) |
| throws <a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></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/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.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>MathIllegalArgumentException</code> if the array is null.</p> |
| <p> |
| Does not change the internal state of the statistic.</p></div> |
| <dl><dt><span class="strong">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="strong">Returns:</span></dt><dd>the variance of the values or Double.NaN if length = 0</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></code> - if the array is null or the array index |
| parameters are not valid</dd></dl> |
| </li> |
| </ul> |
| <a name="evaluate(double[], double)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>evaluate</h4> |
| <pre>public double evaluate(double[] values, |
| double mean) |
| throws <a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></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/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.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>MathIllegalArgumentException</code> if the array is null.</p> |
| <p> |
| Does not change the internal state of the statistic.</p></div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>values</code> - the input array</dd><dd><code>mean</code> - the precomputed mean value</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>the variance of the values or Double.NaN if the array is empty</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></code> - if the array is null</dd></dl> |
| </li> |
| </ul> |
| <a name="evaluate(double[], double[], double, int, int)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>evaluate</h4> |
| <pre>public double evaluate(double[] values, |
| double[] weights, |
| double mean, |
| int begin, |
| int length) |
| throws <a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></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> |
| Σ(weights[i]*(values[i] - mean)<sup>2</sup>)/(Σ(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, MathArrays.normalizeArray(weights, values.length), mean); </code> |
| </pre> |
| <p> |
| Returns 0 for a single-value (i.e. length = 1) sample.</p> |
| <p> |
| Throws <code>MathIllegalArgumentException</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="strong">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="strong">Returns:</span></dt><dd>the variance of the values or Double.NaN if length = 0</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></code> - if the parameters are not valid</dd><dt><span class="strong">Since:</span></dt> |
| <dd>2.1</dd></dl> |
| </li> |
| </ul> |
| <a name="evaluate(double[], double[], double)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>evaluate</h4> |
| <pre>public double evaluate(double[] values, |
| double[] weights, |
| double mean) |
| throws <a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></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> |
| Σ(weights[i]*(values[i] - mean)<sup>2</sup>)/(Σ(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, MathArrays.normalizeArray(weights, values.length), mean); </code> |
| </pre> |
| <p> |
| Returns 0 for a single-value (i.e. length = 1) sample.</p> |
| <p> |
| Throws <code>MathIllegalArgumentException</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="strong">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="strong">Returns:</span></dt><dd>the variance of the values or Double.NaN if length = 0</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></code> - if the parameters are not valid</dd><dt><span class="strong">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 boolean isBiasCorrected()</pre> |
| <dl><dt><span class="strong">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 void setBiasCorrected(boolean biasCorrected)</pre> |
| <dl><dt><span class="strong">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 <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.stat.descriptive.moment">Variance</a> copy()</pre> |
| <div class="block">Returns a copy of the statistic with the same internal state.</div> |
| <dl> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.html#copy()">copy</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.html" title="interface in org.apache.commons.math3.stat.descriptive">StorelessUnivariateStatistic</a></code></dd> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/UnivariateStatistic.html#copy()">copy</a></code> in interface <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/UnivariateStatistic.html" title="interface in org.apache.commons.math3.stat.descriptive">UnivariateStatistic</a></code></dd> |
| <dt><strong>Specified by:</strong></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html#copy()">copy</a></code> in class <code><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.html" title="class in org.apache.commons.math3.stat.descriptive">AbstractStorelessUnivariateStatistic</a></code></dd> |
| <dt><span class="strong">Returns:</span></dt><dd>a copy of the statistic</dd></dl> |
| </li> |
| </ul> |
| <a name="copy(org.apache.commons.math3.stat.descriptive.moment.Variance, org.apache.commons.math3.stat.descriptive.moment.Variance)"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>copy</h4> |
| <pre>public static void copy(<a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.stat.descriptive.moment">Variance</a> source, |
| <a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/Variance.html" title="class in org.apache.commons.math3.stat.descriptive.moment">Variance</a> dest) |
| throws <a href="../../../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></pre> |
| <div class="block">Copies source to dest. |
| <p>Neither source nor dest can be null.</p></div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>source</code> - Variance to copy</dd><dd><code>dest</code> - Variance to copy to</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></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><a href="#skip-navbar_bottom" title="Skip navigation links"></a><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/Variance.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 class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/StandardDeviation.html" title="class in org.apache.commons.math3.stat.descriptive.moment"><span class="strong">Prev Class</span></a></li> |
| <li><a href="../../../../../../../org/apache/commons/math3/stat/descriptive/moment/VectorialCovariance.html" title="class in org.apache.commons.math3.stat.descriptive.moment"><span class="strong">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../../../index.html?org/apache/commons/math3/stat/descriptive/moment/Variance.html" target="_top">Frames</a></li> |
| <li><a href="Variance.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../../../../allclasses-noframe.html">All 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: </li> |
| <li>Nested | </li> |
| <li><a href="#field_summary">Field</a> | </li> |
| <li><a href="#constructor_summary">Constr</a> | </li> |
| <li><a href="#method_summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li><a href="#field_detail">Field</a> | </li> |
| <li><a href="#constructor_detail">Constr</a> | </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 © 2003–2014 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p> |
| </body> |
| </html> |