Standard Deviation - Rapid Calculation Methods

Rapid Calculation Methods

See also: Algorithms for calculating variance

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

Note that s0 raises x to the zero power, and since x0 is always 1, s0 evaluates to N.

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

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 = 0, ..., 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:

Standard variance:

Read more about this topic:  Standard Deviation

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

    The art of watching has become mere skill at rapid apperception and understanding of continuously changing visual images. The younger generation has acquired this cinematic perception to an amazing degree.
    Johan Huizinga (1872–1945)

    “To my thinking” boomed the Professor, begging the question as usual, “the greatest triumph of the human mind was the calculation of Neptune from the observed vagaries of the orbit of Uranus.”
    “And yours,” said the P.B.
    Samuel Beckett (1906–1989)

    The comparison between Coleridge and Johnson is obvious in so far as each held sway chiefly by the power of his tongue. The difference between their methods is so marked that it is tempting, but also unnecessary, to judge one to be inferior to the other. Johnson was robust, combative, and concrete; Coleridge was the opposite. The contrast was perhaps in his mind when he said of Johnson: “his bow-wow manner must have had a good deal to do with the effect produced.”
    Virginia Woolf (1882–1941)