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 12:17:30 -0600 (CST)

On Tue, 12 Nov 2002, Dave Cottingham wrote:

> I see several people have already explained the n - 1, but I have
> another concern.  The method cited here is prone to bad roundoff error
> in cases where sqrt(variance) is much smaller than the mean.  A better
> method would be
>
>    y = sumsq(x - sum(x) / n) / (n - 1);


This is what it was doing...


> >     y = (sumsq (x) - sum(x)^2 / n) / (n-1);


...and I agree that was a very bad choice.  I just want to second Dave's
very sound recommendation.  The formula immediately above (the one now in
use) is sometimes called the "computational formula" for variance, but it
was only given that name because it made it easier for people to compute
the variance by hand (in some situations) and not because it has good
computational properties.

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]