PHP Classes

Turn around variance and stddev

Recommend this page to a friend!

      Numerical  >  All threads  >  Turn around variance and stddev  >  (Un) Subscribe thread alerts  
Subject:Turn around variance and stddev
Summary:I recommend to compute the standard deviation from variance
Messages:2
Author:Martin Weis
Date:2006-01-17 14:40:42
Update:2006-01-19 19:16:17
 

  1. Turn around variance and stddev   Reply   Report abuse  
Picture of Martin Weis Martin Weis - 2006-01-17 14:40:42

Great work, thanks!

I recommend to compute the standard deviation from variance using the sqrt, now you compute the variance as the power of a square, which might be less accurate if the value is small. This is also a little more expensive.

Changes should be little:

function standardDeviation($theSamples)
{
//[...] do this in function variance($theSamples)
// return sqrt($theSum/(count($theSamples) - 1)) ;
return sqrt($this-> variance($theSamples)) ;

}

function variance($theSamples)
{
// put stuff here from above
//return pow(Numerical::standardDeviation($theSamples), 2) ;
}

  2. Re: Turn around variance and stddev   Reply   Report abuse  
Picture of Richard Munroe Richard Munroe - 2006-01-19 19:16:17 - In reply to message 1 from Martin Weis
Good points. I should have thought of that and didn't. The requested change has been made and is available for download.

Thanks for the suggestion.

Dick Munroe