On 18-Feb-11 20:51:40, Dmitry Berman wrote:
> Listers,
> 
> Is there a command/function to get the population standard deviation
> (N) and
> the sample standard deviation (n-1)
> 
> Thanks

Using data (1:10), with N=10, as an example:

  c(SampSD=1, PopSD=sqrt(9/10))*sd((1:10))
  #   SampSD    PopSD
  # 3.027650 2.872281 

More generally, with data x and N<-length(x):

  c(SampSD=1, PopSD=sqrt((N-1)/N))*sd(x)

These are examples of commands. You could wrap the latter into
a function on the lines of:

  PopSampSD <- function(x){
    N <- length(x)
    c(SampSD=1, PopSD=sqrt((N-1)/N))*sd(x)
  }

and then:

  PopSampSD((1:10))
  #   SampSD    PopSD 
  # 3.027650 2.872281 

as before. Hoping this helps,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.hard...@wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 18-Feb-11                                       Time: 22:12:00
------------------------------ XFMail ------------------------------

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
  • [R] Means Dmitry Berman
    • Re: [R] Means Ted Harding

Reply via email to