Concept

Algorithms for calculating variance

Résumé
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. Naïve algorithm A formula for calculating the variance of an entire population of size N is: :\sigma^2 = \overline{(x^2)} - \bar x^2 = \frac {\sum_{i=1}^N x_i^2 - (\sum_{i=1}^N x_i)^2/N}{N}. Using Bessel's correction to calculate an unbiased estimate of the population variance from a finite sample of n observations, the formula is: :s^2 = \left(\frac {\sum_{i=1}^n x_i^2} n - \left( \frac {\sum_{i=1}^n x_i} n \right)^2\right) \cdot \frac {n}{n-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
À propos de ce résultat
Cette page est générée automatiquement et peut contenir des informations qui ne sont pas correctes, complètes, à jour ou pertinentes par rapport à votre recherche. Il en va de même pour toutes les autres pages de ce site. Veillez à vérifier les informations auprès des sources officielles de l'EPFL.
Publications associées

Chargement

Personnes associées

Chargement

Unités associées

Chargement

Concepts associés

Chargement

Cours associés

Chargement

Séances de cours associées

Chargement