Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
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. – Rahul Mar 4 '14 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. – newbie Mar 4 '14 at 7:31
up vote 1 down vote accepted

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 *)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.