# Variance/Standard Deviation with a Constant Vaule

When applying variance (Variance[10]) or standard deviation (StandardDeviation[10]) to a constant value in Mathematica, Should the return be zero ?

What I get from StandardDeviation[10] is the error saying that standardDeviation::rectt: Rectangular array expected at position 1 in StandardDeviation[10].

How do I fix it ?

• For one thing, Variance expects a list, so you'd need to do Variance[{10}] instead. But for another thing, Variance returns the sample variance, with $n-1$ in the denominator, so the variance of a sample of length $n=1$ is not defined at all.
– user484
Mar 4, 2014 at 6:55
• @RahulNarain I guess the way to fix it is to replicate 10 so that I will have a list of {10,10}. Then, applying Variance[{10,10}] returns me 0. Mar 4, 2014 at 7:31

## 1 Answer

As mentioned, a list of one single item has no sample variance but it does have a population variance. The population variance has to be defined, though :

PopulationVariance[list_] := Mean[(list - Mean[list])^2];
PopulationVariance[{10}] (* 0 *)