Algorithms for calculating variance

Short description: Important algorithms in numerical statistics

Algorithms for calculating variance play a major role in computational statistics. A key difficulty in the design of good algorithms for this problem is that formulas for the variance may involve sums of squares, which can lead to numerical instability as well as to arithmetic overflow when dealing with large values.

## Contents

* 1 Naïve algorithm
* 2 Computing shifted data
* 2.1 Two-pass algorithm
* 3 Incremental algorithms
* 3.1 Incremental shifted data
* 3.2 Welford's online algorithm
* 3.3 Weighted incremental algorithm
* 4 Parallel algorithm
* 5 Example
* 6 Higher-order statistics
* 7 Covariance
* 7.1 Naïve algorithm
* 7.2 With estimate of the mean
* 7.3 Two-pass
* 7.4 Online
* 7.5 Weighted batched version
* 8 See also
* 9 References
* 10 External links

## Naïve algorithm

A formula for calculating the variance of an entire population of size N is:

σ2=(x−x¯)2‾=(x2)‾−x¯2=∑i=1Nxi2N−(∑i=1NxiN)2

Using Bessel's correction to calculate an unbiased estimate of the population variance from a finite sample of n observations, the formula is:

s2=(∑i=1nxi2n−(∑i=1nxin)2)⋅nn−1.

Therefore, a naïve algorithm to calculate the estimated variance is given by the following:

* Let n ← 0, Sum ← 0, SumSq ← 0
* For each datum x:
* n ← n \+ 1
* Sum ← Sum + x
* SumSq ← SumSq + x × x
* Var = (SumSq − (Sum × Sum) / n) / (n − 1)

This algorithm can easily be adapted to compute the variance of a finite population: simply divide by n instead of n − 1 on the last line.

Because SumSq and (Sum×Sum)/n can be very similar numbers, cancellation can lead to the precision of the result to be much less than the inherent precision of the floating-point arithmetic used to perform the computation. Thus this algorithm should not be used in practice,[1][2] and several alternate, numerically stable, algorithms have been proposed.[3] This is particularly bad if the standard deviation is small relative to the mean.

## Computing shifted data

The variance is invariant with respect to changes in a location parameter, a property which can be used to avoid the catastrophic cancellation in this formula.

Var⁡(X−K)=Var⁡(X).

with K any constant, which leads to the new formula

σ2=∑i=1n(xi−K)2−(∑i=1n(xi−K))2/nn−1.

the closer K is to the mean value the more accurate the result will be, but just choosing a value inside the samples range will guarantee the desired stability. If the values (xi−K) are small then there are no problems with the sum of its squares, on the contrary, if they are large it necessarily means that the variance is large as well. In any case the second term in the formula is always smaller than the first one therefore no cancellation may occur.[2]

If just the first sample is taken as K the algorithm can be written in Python programming language as

def shifted_data_variance(data):
if len(data) < 2:
return 0.0
K = data[0]
n = Ex = Ex2 = 0.0
for x in data:
n += 1
Ex += x - K
Ex2 += (x - K) ** 2
variance = (Ex2 - Ex**2 / n) / (n - 1)
# use n instead of (n-1) if want to compute the exact variance of the given data
# use (n-1) if data are samples of a larger population
return variance

### Two-pass algorithm

An alternative approach, using a different formula for the variance, first computes the sample mean,

x¯=∑j=1nxjn,

and then computes the sum of the squares of the differences from the mean,

sample variance=s2=∑i=1n(xi−x¯)2n−1,

where s is the standard deviation. This is given by the following code:

def two_pass_variance(data):
n = len(data)
mean = sum(data) / n
variance = sum((x - mean) ** 2 for x in data) / (n - 1)
return variance

This piece of code, if run on CPython 3.12 and newer, is always numerically stable. This is because these versions use Neumaier's compensated summation scheme for the `sum()` function, making it resistant to repeated roundoff error.[4] Many numerically-oriented languages provide similar constructs.

This algorithm, if implemented with a naive addition `sum = 0; for x in data: sum += x; mean = sum / n`, would only be numerically stable if n is small because of the accumulation of roundoff error.[1][5]

## Incremental algorithms

It is often useful to be able to compute the variance in a single pass, inspecting each value xi only once; for example, when the data is being collected without enough storage to keep all the values, or when costs of memory access dominate those of computation. For such an online algorithm, a recurrence relation is required between quantities from which the required statistics can be calculated in a numerically stable fashion.

### Incremental shifted data

Our shifted-data algorithm from before includes the simple updating of data in a loop, which is naturally incremental. It can be expressed as:[2]

class ShiftDataVariance:
def __init__(self):
self.K = 0.0
self.n = 0
self.Ex = 0.0
self.Ex2 = 0.0

def add_variable(self, x: float):
if self.n == 0:
self.K = x
self.n += 1
self.Ex += x - self.K
self.Ex2 += (x - self.K) ** 2

def remove_variable(self, x: float):
self.n -= 1
self.Ex -= x - self.K
self.Ex2 -= (x - self.K) ** 2

def add_variables(self, xs: list[float]):
# Python uses Neumaier's algorithm for the builtin sum() function,
# which is more accurate than a simple loop.
if self.n == 0 and xs:
self.K = xs[0]
self.n += len(xs)
self.Ex += sum(x - self.K for x in xs)
self.Ex2 += sum((x - self.K) ** 2 for x in xs)

def get_mean(self) -> float:
return self.K + self.Ex / self.n

def get_variance(self) -> float:
return (self.Ex2 - self.Ex**2 / self.n) / (self.n - 1)

### Welford's online algorithm

Analogous to the two-pass algorithm above, it remains desirable to use the actual mean of the data instead of just picking the first element. The following formulas can be used to update the mean and (estimated) variance of the sequence, for an additional element xn. Here, x‾n=1n∑i=1nxi denotes the sample mean of the first n samples (x1,…,xn), σn2=1n∑i=1n(xi−x‾n)2 their biased sample variance, and sn2=1n−1∑i=1n(xi−x‾n)2 their unbiased sample variance.

x¯n=(n−1)x¯n−1+xnn=x¯n−1+xn−x¯n−1n

σn2=(n−1)σn−12+(xn−x¯n−1)(xn−x¯n)n=σn−12+(xn−x¯n−1)(xn−x¯n)−σn−12n.

sn2=n−2n−1sn−12+(xn−x¯n−1)2n=sn−12+(xn−x¯n−1)2n−sn−12n−1,n>1

These formulas suffer from numerical instability, as they repeatedly subtract a small number from a big number which scales with n. A better quantity for updating is the sum of squares of differences from the current mean, ∑i=1n(xi−x¯n)2, here denoted M2,n:

M2,n=M2,n−1+(xn−x¯n−1)(xn−x¯n)σn2=M2,nnsn2=M2,nn−1

The following algorithm was found by Welford,[6][7] and it has been thoroughly analyzed.[2][8] It is also common to denote Mk=x¯k and Sk=M2,k.[9] An example Python implementation for Welford's algorithm is given below, using the same framework as the above "shifted data" algorithm:

class WelfordVariance:
def __init__(self):   # Comparison to ShiftDataVariance:
self.mean = 0.0   # = K + Ex / n
self.count = 0    # = n
self.M2 = 0.0     # = Ex2 - (Ex)^2 / n

def add_variable(self, x: float):
self.count += 1
old_mean = self.mean
self.mean += (x - self.mean) / self.count
self.M2 += (x - old_mean) * (x - self.mean)

def remove_variable(self, x: float):
self.count -= 1
new_mean = self.mean
self.mean -= (x - self.mean) / self.count
self.M2 -= (x - new_mean) * (x - self.mean)

def get_mean(self) -> float:
return self.mean

def get_variance(self) -> float:
return self.M2 / self.count

def get_sample_variance(self) -> float:
return self.M2 / (self.count - 1)

This algorithm is much less prone to loss of precision due to catastrophic cancellation, but might not be as efficient because of the division operation inside the loop. For a particularly robust two-pass algorithm for computing the variance, one can first compute and subtract an estimate of the mean, and then use this algorithm on the residuals.

The parallel algorithm below illustrates how to merge multiple sets of statistics calculated online.

### Weighted incremental algorithm

The algorithm can be extended to handle unequal sample weights, replacing the simple counter n with the sum of weights seen so far. West (1979)[10] suggests this incremental algorithm:

from collections import namedtuple
WeightedVariances = namedtuple("WeightedVariances", "pop freq reli")
def weighted_incremental_variance(data_weight_pairs):
w_sum = w_sum2 = mean = S = 0

for x, w in data_weight_pairs:
w_sum = w_sum + w
w_sum2 = w_sum2 + w**2
mean_old = mean
mean = mean_old + (w / w_sum) * (x - mean_old)
S = S + w * (x - mean_old) * (x - mean)

population_variance = S / w_sum
# Bessel's correction for weighted samples
# Frequency weights
sample_frequency_variance = S / (w_sum - 1)

# Reliability weights
sample_reliability_variance = S / (w_sum - w_sum2 / w_sum)
return WeightedVariances(population_variance, sample_frequency_variance, sample_reliability_variance)

## Parallel algorithm

Chan et al.[11] note that Welford's online algorithm detailed above is a special case of an algorithm that works for combining arbitrary sets A and B:

nAB=nA+nBδ=x¯B−x¯Ax¯AB=x¯A+δ⋅nBnABM2,AB=M2,A+M2,B+δ2⋅nAnBnAB.

This may be useful when, for example, multiple processing units may be assigned to discrete parts of the input.

Chan's method for estimating the mean is numerically unstable when nA≈nB and both are large, because the numerical error in δ=x¯B−x¯A is not scaled down in the way that it is in the nB=1 case. In such cases, prefer x¯AB=nAx¯A+nBx¯BnAB. Reusing the `WelfordVariance` class from above, we have:

def merge(a: WelfordVariance, b: WelfordVariance) -> WelfordVariance:
ab = WelfordVariance()
ab.count = a.count + b.count
delta = b.mean - a.mean
ab.mean = (a.count * a.mean + b.count * b.mean) / ab.count
ab.M2 = a.M2 + b.M2 + delta**2 * a.count * b.count / ab.count
return ab

# example:
ab = merge(a, b)
print(ab.get_sample_variance())

This algorithm allows one to divide a dataset into several pieces, run them in parallel, and then merge the results together. This enables parallelization in any way, including AVX, with GPUs, and computer clusters. The algorithm can also be adapted for higher-order statistics as well as covariance.[3][12]

## Example

Assume that all floating point operations use standard IEEE 754 double-precision arithmetic. Consider the sample (4, 7, 13, 16) from an infinite population. Based on this sample, the estimated population mean is 10, and the unbiased estimate of population variance is 30. Both the naïve algorithm and two-pass algorithm compute these values correctly.

Next consider the sample (108 + 4, 108 + 7, 108 + 13, 108 + 16), which gives rise to the same estimated variance as the first sample. The two-pass algorithm computes this variance estimate correctly, but the naïve algorithm returns 29.333333333333332 instead of 30.

While this loss of precision may be tolerable and viewed as a minor flaw of the naïve algorithm, further increasing the offset makes the error catastrophic. Consider the sample (109 + 4, 109 + 7, 109 + 13, 109 + 16). Again the estimated population variance of 30 is computed correctly by the two-pass algorithm, but the naïve algorithm now computes it as −170.66666666666666. This is a serious problem with naïve algorithm and is due to catastrophic cancellation in the subtraction of two similar numbers at the final stage of the algorithm.

## Higher-order statistics

Terriberry[12] extends Chan's formulae to calculating the third and fourth central moments, needed for example when estimating skewness and kurtosis:

M3,X=M3,A+M3,B+δ3nAnB(nA−nB)nX2+3δnAM2,B−nBM2,AnXM4,X=M4,A+M4,B+δ4nAnB(nA2−nAnB+nB2)nX3+6δ2nA2M2,B+nB2M2,AnX2+4δnAM3,B−nBM3,AnX

Here the Mk are again the sums of powers of differences from the mean ∑(x−x‾)k, giving

skewness=g1=nM3M23/2,kurtosis=g2=nM4M22−3.

For the incremental case (i.e., B={x}), this simplifies to:

δ=x−mm′=m+δnM2′=M2+δ2n−1nM3′=M3+δ3(n−1)(n−2)n2−3δM2nM4′=M4+δ4(n−1)(n2−3n+3)n3+6δ2M2n2−4δM3n

By preserving the value δ/n, only one division operation is needed and the higher-order statistics can thus be calculated for little incremental cost.

An example of the online algorithm for kurtosis implemented as described is:

def online_kurtosis(data):
n = mean = M2 = M3 = M4 = 0

for x in data:
n1 = n
n = n + 1
delta = x - mean
delta_n = delta / n
delta_n2 = delta_n**2
term1 = delta * delta_n * n1
mean = mean + delta_n
M4 = M4 + term1 * delta_n2 * (n**2 - 3*n + 3) + 6 * delta_n2 * M2 - 4 * delta_n * M3
M3 = M3 + term1 * delta_n * (n - 2) - 3 * delta_n * M2
M2 = M2 + term1

# Note, you may also calculate variance using M2, and skewness using M3
# Caution: If all the inputs are the same, M2 will be 0, resulting in a division by 0.
kurtosis = (n * M4) / (M2**2) - 3
return kurtosis

Pébaÿ[13] further extends these results to arbitrary-order central moments, for the incremental and the pairwise cases, and subsequently Pébaÿ et al.[14] for weighted and compound moments. One can also find there similar formulas for covariance.

Choi and Sweetman[15] offer two alternative methods to compute the skewness and kurtosis, each of which can save substantial computer memory requirements and CPU time in certain applications. The first approach is to compute the statistical moments by separating the data into bins and then computing the moments from the geometry of the resulting histogram, which effectively becomes a one-pass algorithm for higher moments. One benefit is that the statistical moment calculations can be carried out to arbitrary accuracy such that the computations can be tuned to the precision of, e.g., the data storage format or the original measurement hardware. A relative histogram of a random variable can be constructed in the conventional way: the range of potential values is divided into bins and the number of occurrences within each bin are counted and plotted such that the area of each rectangle equals the portion of the sample values within that bin:

H(xk)=h(xk)A

where h(xk) and H(xk) represent the frequency and the relative frequency at bin xk and A=∑k=1Kh(xk)Δxk is the total area of the histogram. After this normalization, the n raw moments and central moments of x(t) can be calculated from the relative histogram:

mn(h)=∑k=1KxknH(xk)Δxk=1A∑k=1Kxknh(xk)Δxk
θn(h)=∑k=1K(xk−m1(h))nH(xk)Δxk=1A∑k=1K(xk−m1(h))nh(xk)Δxk

where the superscript  (h) indicates the moments are calculated from the histogram. For constant bin width Δxk=Δx these two expressions can be simplified using I=A/Δx:

mn(h)=1I∑k=1Kxknh(xk)

θn(h)=1I∑k=1K(xk−m1(h))nh(xk)

The second approach from Choi and Sweetman[15] is an analytical methodology to combine statistical moments from individual segments of a time-history such that the resulting overall moments are those of the complete time-history. This methodology could be used for parallel computation of statistical moments with subsequent combination of those moments, or for combination of statistical moments computed at sequential times.

If Q sets of statistical moments are known: (γ0,q,μq,σq2,α3,q,α4,q) for q=1,2,…,Q, then each γn can be expressed in terms of the equivalent n raw moments:

γn,q=mn,qγ0,qforn=1,2,3,4 and q=1,2,…,Q

where γ0,q is generally taken to be the duration of the qth time-history, or the number of points if Δt is constant.

The benefit of expressing the statistical moments in terms of γ is that the Q sets can be combined by addition, and there is no upper limit on the value of Q.

γn,c=∑q=1Qγn,qfor n=0,1,2,3,4

where the subscript c represents the concatenated time-history or combined γ. These combined values of γ can then be inversely transformed into raw moments representing the complete concatenated time-history

mn,c=γn,cγ0,cfor n=1,2,3,4

Known relationships between the raw moments (mn) and the central moments (θn=E⁡[(x−μ)n])) are then used to compute the central moments of the concatenated time-history. Finally, the statistical moments of the concatenated history are computed from the central moments:

μc=m1,cσc2=θ2,cα3,c=θ3,cσc3α4,c=θ4,cσc4−3

## Covariance

Very similar algorithms can be used to compute the covariance.

### Naïve algorithm

The naïve algorithm is

Cov⁡(X,Y)=∑i=1nxiyi−(∑i=1nxi)(∑i=1nyi)/nn.

For the algorithm above, one could use the following Python code:

def naive_covariance(data1, data2):
n = len(data1)
sum1 = sum(data1)
sum2 = sum(data2)
sum12 = sum([i1 * i2 for i1, i2 in zip(data1, data2)])

covariance = (sum12 - sum1 * sum2 / n) / n
return covariance

### With estimate of the mean

As for the variance, the covariance of two random variables is also shift-invariant, so given any two constant values kx and ky, it can be written:

Cov⁡(X,Y)=Cov⁡(X−kx,Y−ky)=∑i=1n(xi−kx)(yi−ky)−(∑i=1n(xi−kx))(∑i=1n(yi−ky))/nn.

and again choosing a value inside the range of values will stabilize the formula against catastrophic cancellation as well as make it more robust against big sums. Taking the first value of each data set, the algorithm can be written as:

def shifted_data_covariance(data_x, data_y):
n = len(data_x)
if n < 2:
return 0
kx = data_x[0]
ky = data_y[0]
Ex = Ey = Exy = 0
for ix, iy in zip(data_x, data_y):  # for higher precision, use sum():
Ex += ix - kx                   # Ex = sum(ix - kx for ix in data_x)  # or sum(ix) - kx * n
Ey += iy - ky                   # Ey = sum(iy - ky for iy in data_y)  # or sum(iy) - ky * n
Exy += (ix - kx) * (iy - ky)    # Exy = sum((ix - kx) * (iy - ky) for ix, iy in zip(data_x, data_y))
return (Exy - Ex * Ey / n) / n

### Two-pass

The two-pass algorithm first computes the sample means, and then the covariance:

x¯=∑i=1nxi/n
y¯=∑i=1nyi/n
Cov⁡(X,Y)=∑i=1n(xi−x¯)(yi−y¯)n.

The two-pass algorithm may be written as:

def two_pass_covariance(data1, data2):
n = len(data1)
mean1 = sum(data1) / n
mean2 = sum(data2) / n

covariance = 0
for i1, i2 in zip(data1, data2):    # for higher precision, use sum():
a = i1 - mean1                  # covariance = sum((i1 - mean1) * (i2 - mean2) for i1, i2 in zip(data1, data2))
b = i2 - mean2
covariance += a * b / n
return covariance

### Online

A stable one-pass algorithm exists, similar to the online algorithm for computing the variance, that computes co-moment Cn=∑i=1n(xi−x¯n)(yi−y¯n):

x¯n=x¯n−1+xn−x¯n−1ny¯n=y¯n−1+yn−y¯n−1nCn=Cn−1+(xn−x¯n)(yn−y¯n−1)=Cn−1+(xn−x¯n−1)(yn−y¯n)

The apparent asymmetry in that last equation is due to the fact that (xn−x¯n)=n−1n(xn−x¯n−1), so both update terms are equal to n−1n(xn−x¯n−1)(yn−y¯n−1). Even greater accuracy can be achieved by first computing the means, then using the stable one-pass algorithm on the residuals.

Thus the covariance can be computed as

CovN(X,Y)=CNN=CovN−1(X,Y)⋅(N−1)+(xn−x¯n)(yn−y¯n−1)N=CovN−1(X,Y)⋅(N−1)+(xn−x¯n−1)(yn−y¯n)N=CovN−1(X,Y)⋅(N−1)+N−1N(xn−x¯n−1)(yn−y¯n−1)N=CovN−1(X,Y)⋅(N−1)+NN−1(xn−x¯n)(yn−y¯n)N.

def online_covariance(data1, data2):
meanx = meany = C = n = 0
for x, y in zip(data1, data2):
n += 1
dx = x - meanx
meanx += dx / n
meany += (y - meany) / n
C += dx * (y - meany)

# covariance and Bessel's correction for sample
return (C / n, C / (n - 1))

A small modification can also be made to compute the weighted covariance:

def online_weighted_covariance(data1, data2, data3):
meanx = meany = 0
wsum = wsum2 = 0
C = 0
for x, y, w in zip(data1, data2, data3):
wsum += w
wsum2 += w * w
dx = x - meanx
meanx += (w / wsum) * dx
meany += (w / wsum) * (y - meany)
C += w * dx * (y - meany)

population_covar = C / wsum
# Bessel's correction for sample variance
# Frequency weights
sample_frequency_covar = C / (wsum - 1)
# Reliability weights
sample_reliability_covar = C / (wsum - wsum2 / wsum)

Likewise, there is a formula for combining the covariances of two sets that can be used to parallelize the computation:[3]

CX=CA+CB+(x¯A−x¯B)(y¯A−y¯B)⋅nAnBnX.

### Weighted batched version

A version of the weighted online algorithm that does batched updated also exists: let w1,…wN denote the weights, and write

x¯n+k=x¯n+∑i=n+1n+kwi(xi−x¯n)∑i=1n+kwiy¯n+k=y¯n+∑i=n+1n+kwi(yi−y¯n)∑i=1n+kwiCn+k=Cn+∑i=n+1n+kwi(xi−x¯n+k)(yi−y¯n)=Cn+∑i=n+1n+kwi(xi−x¯n)(yi−y¯n+k)

The covariance can then be computed as

CovN(X,Y)=CN∑i=1Nwi

(This can be used with Python's `sum` for better accuracy. Block updating is also related to the parallel/merge algorithm.)

## See also

* Kahan summation algorithm
* Squared deviations from the mean
* Yamartino method

## References

1. ↑ 1.0 1.1 Einarsson, Bo (2005). Accuracy and Reliability in Scientific Computing. SIAM. p. 47. ISBN 978-0-89871-584-2. https://books.google.com/books?id=8hrDV5EbrEsC.
2. ↑ 2.0 2.1 2.2 2.3 Chan, Tony F.; Golub, Gene H.; LeVeque, Randall J. (1983). "Algorithms for computing the sample variance: Analysis and recommendations". The American Statistician 37 (3): 242–247. doi:10.1080/00031305.1983.10483115. http://cpsc.yale.edu/sites/default/files/files/tr222.pdf.
3. ↑ 3.0 3.1 3.2 Schubert, Erich; Gertz, Michael (2018-07-09). Numerically stable parallel computation of (co-)variance. ACM. pp. 10. doi:10.1145/3221269.3223036. ISBN 9781450365055. http://dl.acm.org/citation.cfm?id=3221269.3223036.
4. ↑

* What's New in Python 3.12
* Hettinger, R.. "Improve accuracy of builtin sum() for float inputs · Issue #100425 · python/cpython" (in en). https://github.com/python/cpython/issues/100425.

5. ↑ Higham, Nicholas J. (2002). "Problem 1.10". Accuracy and Stability of Numerical Algorithms (2nd ed.). Philadelphia, PA: Society for Industrial and Applied Mathematics. doi:10.1137/1.9780898718027. eISBN 978-0-89871-802-7, 2002075848. ISBN 978-0-898715-21-7. https://epubs.siam.org/doi/book/10.1137/1.9780898718027. Metadata also listed at ACM Digital Library.
6. ↑ Welford, B. P. (1962). "Note on a method for calculating corrected sums of squares and products". Technometrics 4 (3): 419–420. doi:10.2307/1266577.
7. ↑ Donald E. Knuth (1998). The Art of Computer Programming, volume 2: Seminumerical Algorithms, 3rd edn., p. 232\. Boston: Addison-Wesley.
8. ↑ Ling, Robert F. (1974). "Comparison of Several Algorithms for Computing Sample Means and Variances". Journal of the American Statistical Association 69 (348): 859–866. doi:10.2307/2286154.
9. ↑ Cook, John D. (30 September 2022). "Accurately computing sample variance". http://www.johndcook.com/standard_deviation.html.
10. ↑ West, D. H. D. (1979). "Updating Mean and Variance Estimates: An Improved Method". Communications of the ACM 22 (9): 532–535. doi:10.1145/359146.359153.
11. ↑ Chan, Tony F.; Golub, Gene H.; LeVeque, Randall J. (November 1979). "Updating Formulae and a Pairwise Algorithm for Computing Sample Variances". Department of Computer Science, Stanford University. http://i.stanford.edu/pub/cstr/reports/cs/tr/79/773/CS-TR-79-773.pdf.
12. ↑ 12.0 12.1 Terriberry, Timothy B. (15 October 2008). "Computing Higher-Order Moments Online". http://people.xiph.org/~tterribe/notes/homs.html.
13. ↑ Pébay, Philippe Pierre (September 2008). "Formulas for Robust, One-Pass Parallel Computation of Covariances and Arbitrary-Order Statistical Moments". Sandia National Laboratories (SNL). doi:10.2172/1028931. https://digital.library.unt.edu/ark:/67531/metadc837537/.
14. ↑ Pébaÿ, Philippe; Terriberry, Timothy; Kolla, Hemanth; Bennett, Janine (2016). "Numerically Stable, Scalable Formulas for Parallel and Online Computation of Higher-Order Multivariate Central Moments with Arbitrary Weights". Computational Statistics (Springer) 31 (4): 1305–1325. doi:10.1007/s00180-015-0637-z. https://zenodo.org/record/1232635.
15. ↑ 15.0 15.1 Choi, Myoungkeun; Sweetman, Bert (2010). "Efficient Calculation of Statistical Moments for Structural Health Monitoring". Journal of Structural Health Monitoring 9 (1): 13–24. doi:10.1177/1475921709341014.

## External links

* Weisstein, Eric W.. "Sample Variance Computation". http://mathworld.wolfram.com/SampleVarianceComputation.html.

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Algorithms for calculating variance. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Algorithms_for_calculating_variance&oldid=4227086"