help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: var(x) and std(x)


From: Mike Miller
Subject: Re: var(x) and std(x)
Date: Tue, 12 Nov 2002 09:48:31 -0600 (CST)

On Tue, 12 Nov 2002, Anand V wrote:

>   I have a doubt regarding the implementation of variance function
> var(x) in octave.
[snip]

>    It gives variance after averaging over n-1 samples, rather than
> averaging over n samples. for example, if we calculate the variance of x
> = [1,2,3] , it returns the value 1, instead of 2/3..This is because it
> finds 2/2 and not 2/3..The same is the case with std(x) also.
> Is it an error or is there any explanation for that?


It is not an error.  Variances are computed as the sum of squared
deviations about the mean divided by some term.  One might divide by n,
but this produces an estimator that is biased, so it is more common to
divide by n-1 because use of n-1 produces a variance estimator that is
unbiased.  Octave and MATLAB both use n-1 in var and std.  It's a good
choice, I think.

So, Octave uses all n values, but it divides the sum of squares by n-1.

Mike

-- 
Michael B. Miller, Ph.D.
Assistant Professor
Division of Epidemiology
University of Minnesota
http://taxa.epi.umn.edu/~mbmiller/



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]