-1

the function sd() in R seems to calculate standard deviation of a sample, how can I calculate standard deviation of a population,is there a function ?

hariharan s
  • 165
  • 1
  • 11
  • What do you mean? What exactly your expectation is? – MKR Jun 16 '18 at 11:35
  • You can write your own function to calculate the population standard deviation. – www Jun 16 '18 at 11:40
  • 1
    I think there is a misconception here: The population variance (and thence the sd) is something you get from a statistical inference method and can be estimated from an appropriate statistical model fit to your sample data. That's the whole point of statistical inference. There is no single "function" to do this. – Maurits Evers Jun 16 '18 at 12:10
  • Whats off-topic in this question ?it is so simple and clear, some folks have answered it ,it means they understood it.. – hariharan s Jun 17 '18 at 02:05
  • Please read my previous comment. Estimating population parameters is the whole point of statistical inference. There exists no "single function" to do this. It depends on the underlying probability distribution, etc. In general terms, below answer does *not* give you the "standard deviation of a population". If you want to know more start with any Stats textbook. As this is not a specific coding question, your question is OT as per SO guidelines (which you should consult). – Maurits Evers Jun 17 '18 at 11:03
  • ok,i realised your point yesterday when i was finishing the course.Thanks – hariharan s Jun 18 '18 at 11:58
  • While I respect R and the community, the responses to this OP are shocking. The OP is obviously asking for something in R, that is done in other packages like NumPy: https://stackoverflow.com/questions/34050491/standard-deviation-in-numpy This link in itself disproves the comment, "...there is no single 'function' to do this." The downvotes are people who have disciplines thinking of inferring a population result based samples. sometimes we have disciplines that have populations and want to describe them in their spread (variance, sd) and such a function should be expected in a stats package. – continuousqa Mar 27 '19 at 20:55

1 Answers1

3

This is fairly inline with the below question: Population Variance in r

I would simply include sqrt aspect for the sd:

x <- 1:10
sdp <- function(x) sqrt(mean((x-mean(x))^2))
sdp(x)
RK1
  • 2,384
  • 1
  • 19
  • 36
  • This is a great answer, but I still don't understand why R doesn't include a population variance and population std function built in? Considering NumPy has such built in, I would think every Stats package would include a param to switch the calculation from population to sample - as sometimes we want to describe a population we know, and other times we want to infer a result from a sample. – continuousqa Mar 27 '19 at 20:47