Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The answer is to use Welford's algorithm, which is very clearly defined after the "naive methods" in:</p> <ul> <li>Wikipedia: <a href="http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance" rel="noreferrer">Algorithms for calculating variance</a> </ul> <p>It's more numerically stable than either the two-pass or online simple sum of squares collectors suggested in other responses. The stability only really matters when you have lots of values that are close to each other as they lead to what is known as "<a href="http://www.cs.princeton.edu/introcs/lectures/9scientific.pdf" rel="noreferrer">catastrophic cancellation</a>" in the floating point literature.</p> <p>You might also want to brush up on the difference between dividing by the number of samples (N) and N-1 in the variance calculation (squared deviation). Dividing by N-1 leads to an unbiased estimate of variance from the sample, whereas dividing by N on average underestimates variance (because it doesn't take into account the variance between the sample mean and the true mean).</p> <p>I wrote two blog entries on the topic which go into more details, including how to delete previous values online:</p> <ul> <li><a href="http://lingpipe-blog.com/2009/03/19/computing-sample-mean-variance-online-one-pass/" rel="noreferrer">Computing Sample Mean and Variance Online in One Pass</a> <li><a href="http://lingpipe-blog.com/2009/07/07/welford-s-algorithm-delete-online-mean-variance-deviation/" rel="noreferrer">Deleting Values in Welford’s Algorithm for Online Mean and Variance</a> </ul> <p>You can also take a look at my Java implement; the javadoc, source, and unit tests are all online:</p> <ul> <li><a href="http://alias-i.com/lingpipe/docs/api/com/aliasi/stats/OnlineNormalEstimator.html" rel="noreferrer">Javadoc: <code>stats.OnlineNormalEstimator</code></a> <li><a href="http://alias-i.com/lingpipe/src/com/aliasi/stats/OnlineNormalEstimator.java" rel="noreferrer">Source: <code>stats.OnlineNormalEstimator.java</code></a> <li><a href="http://alias-i.com/lingpipe/src/com/aliasi/test/unit/stats/OnlineNormalEstimatorTest.java" rel="noreferrer">JUnit Source: <code>test.unit.stats.OnlineNormalEstimatorTest.java</code></a> <li><a href="http://alias-i.com/lingpipe" rel="noreferrer">LingPipe Home Page</a> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload