[R] Different results in calculating SD of 2 numbers

Daniel Nordlund res90sx5 at verizon.net
Wed Jan 16 09:39:00 CET 2008


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of Ron Michael
> Sent: Wednesday, January 16, 2008 12:15 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Different results in calculating SD of 2 numbers
> 
> Hi all,
> 
> Can anyone tell me why I am getting different results in calculating SD of 2 numbers ?
> 
> > (1.25-0.95)/2
> [1] 0.15

Because the above is not the standard deviation of two numbers.  The sample based estimate of the population standard deviation of a set of numbers (which is what sd() computes) is 

(sum((x-mean(x))^2 )/(length(x)-1))^.5

which for your two numbers would be

( (1.25 - 1.1)^2 + (.95 - 1.1)^2 )^.5

> > sd(c(1.25, 0.95))
> [1] 0.2121320          # why it is different from 0.15?
> 
> Regards,
> 

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA  USA




More information about the R-help mailing list