in reply to Re: variance calculation
in thread variance calculation

... maybe you actually want the number of array elements minus 1?

Dividing by n is okay for purely descriptive purposes, i.e. when you're simply making a statement about the variability in the sample itself. If you're using the value as an estimate of the underlying population's variance, however, then use n - 1.

It can be shown that the variance of a concrete sample is a biased estimate of the variance found in the population the sample is drawn from. Using n - 1 compensates for that bias.  For larger sample sizes, it doesn't make much difference anyway.

In short, it's n for descriptive statistics, and n - 1 in the context of inferential statistics.