Tool to calculate the variance of a list of values. Variance is a statistical value that measures the dispersion characteristic of a distribution or sample.
Statistical Variance - dCode
Tag(s) : Statistics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
Variance is a measure of the dispersion of a list of values around its mean value. This value, denoted $ V $ or $ \mathbb{V} $ or $ \mathrm{Var} $ or $ \sigma^2 $ or $ s^2 $ characterizes the way in which the data $ X $ (random variable) are dispersed by measuring the deviations between each value (of the variable) and the mean value (or expected value $ \mathbb{E} $).
$$ V(X) = \mathbb{E} \left[(X - \mathbb{E}[X])^{2}\right] $$
or
$$ V(X) = \mathbb{E} \left[X^{2}\right]-\mathbb{E}[X]^{2} $$
A list of numbers $ x_i $ of a discrete random variable $ X $ whose mean alue is $ m $ and with an unknown distribution, has for variance $ V $ according to the formula $$ V(X)= \frac{1}{n} \sum_{i=1}^{n}(x_{i}-m)^2 $$
When the list of numbers comes from a sample, then it is usual to use the formula for calculating the corrected/empirical variance called unbiased $$ V(X)= \frac{1}{n-1} \sum_{i=1}^{n}(x_{i}-m)^2 $$
Example: The (unbiased) variance of the set of 3 numbers 1,2,9 with a mean value of 4 is $ V = \frac{1}{3-1} \left( (1-4)^2 + (2-4)^2 + (9-4)^2 \right) = 38/2 = 19 $
When the list of numbers is taken from a sample, the calculated variance will generally not match the actual variance that would have been calculated from the full population.
Indeed, the average used is calculated from the sample (and not from the full population, so it is an empirical estimate with limited precision). The variance thus calculated is a biased estimator that underestimates the variance by a factor of $(n-1)$.
One way to reduce the bias introduced by this estimate is to no longer divide by $ n $ but by $ n-1 $. This method is also called Bessel correction.
If the true mean is known (or determined in some way) then this bias does not occur and the variance can be estimated without correction.
An alternative method is to divide by $ n+1 $ to minimize the mean square error for the normal distribution. The estimator remains biased in this case.
When the true mean of the population from which the list of numbers is derived is not known, then the mean is estimated from the list of numbers (and therefore may be slightly inaccurate).
The sample variance is calculated as an average of the squares of the deviations from the (sample) mean $ V(X)= \frac{1}{n} \sum_{i=1}^{n}(x_{i}-m)^2 $
The expectation is then biased $$ \mathbb{E}(V(X))= \frac{n-1}{n}\sigma^{2} $$ by a factor $ \frac{n-1}{n} $ which can be removed by multiplying the formula by $ \frac{n}{n-1} $ which amounts to dividing by $ n-1 $ in the formula $ V(X)= \frac{1}{n-1} \sum_{i=1}^{n}(x_{i}-m)^2 $
The value of the variance is the square of the standard deviation. Knowing the value of the standard deviation $ \sigma $, $ V $ can be calculated with the relation: $$ V(X) = \sigma^{2}(X) $$
dCode retains ownership of the "Statistical Variance" source code. Except explicit open source licence (indicated Creative Commons / free), the "Statistical Variance" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "Statistical Variance" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Statistical Variance" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.
The copy-paste of the page "Statistical Variance" or any of its results, is allowed (even for commercial purposes) as long as you credit dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
Statistical Variance on dCode.fr [online website], retrieved on 2024-11-21,