[R] Standard Deviation in R
S Ellison
S.Ellison at LGCGroup.com
Thu Jun 12 12:18:08 CEST 2014
> > The formula I generally use to compute the standard deviation is the
> square root of the variance where the variance is E(X^2) - (E(x))^2.
Even if that is what you want, I hope you don't _implement_ it that way (eg as mean(x^2)-mean(x)^2. _Serious_ numerical rounding issues...
#Example:
set.seed(1023)
x<-rnorm(200, 1e9)
# Compare
199*var(x)/200 #"Population" variance
#with
mean(x^2)-mean(x)^2
#Other seeds give differently wrong numbers.
#See FAQ 7.31 for why
S Ellison
*******************************************************************
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If
you have received this message in error, please notify the sender
immediately via +44(0)20 8943 7000 or notify postmaster at lgcgroup.com
and delete this message and any copies from your computer and network.
LGC Limited. Registered in England 2991879.
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
More information about the R-help
mailing list