Sample Standard Deviation - Rapid Calculation Methods

Rapid Calculation Methods

It has been suggested that this article be merged into Algorithms for calculating variance. (Discuss)

The following two formulas can represent a running (continuous) standard deviation. A set of two power sums s1 and s2 are computed over a set of N values of x, denoted as x1, ..., xN:

Given the results of these three running summations, the values N, s1, s2 can be used at any time to compute the current value of the running standard deviation:

Where :

Similarly for sample standard deviation,

In a computer implementation, as the three sj sums become large, we need to consider round-off error, arithmetic overflow, and arithmetic underflow. The method below calculates the running sums method with reduced rounding errors. This is a "one pass" algorithm for calculating variance of n samples without the need to store prior data during the calculation. Applying this method to a time series will result in successive values of standard deviation corresponding to n data points as n grows larger with each new sample, rather than a constant-width sliding window calculation.

For k = 1, ..., n:

\begin{align}
A_0 &= 0\\
A_k &= A_{k-1}+\frac{x_k-A_{k-1}}{k}
\end{align}

where A is the mean value.

\begin{align}
Q_0 &= 0\\
Q_k &= Q_{k-1}+\frac{k-1}{k} (x_k-A_{k-1})^2 = Q_{k-1}+ (x_k-A_{k-1})(x_k-A_k)
\end{align}

Sample variance:

Population variance:

Read more about this topic:  Sample Standard Deviation

Famous quotes containing the words rapid, calculation and/or methods:

    In a time of confusion and rapid change like the present, when terms are continually turning inside out and the names of things hardly keep their meaning from day to day, it’s not possible to write two honest paragraphs without stopping to take crossbearings on every one of the abstractions that were so well ranged in ornate marble niches in the minds of our fathers.
    John Dos Passos (1896–1970)

    Common sense is the measure of the possible; it is composed of experience and prevision; it is calculation appled to life.
    Henri-Frédéric Amiel (1821–1881)

    If men got pregnant, there would be safe, reliable methods of birth control. They’d be inexpensive, too.
    Anna Quindlen (b. 1952)