# How to calculate difference between sample and population mean in R [closed]

I am taking a statistics course focused on R and was asked this question about a normally distributed sample of weights:

Use the CLT to approximate the probability that our sample mean estimate is off by more than 2 grams from the population mean.

2 * ( 1-pnorm(2/sd(X) * sqrt(12) ) )


I understand why the value is multiplied by 2 (to estimate for a difference greater than 2 and less than -2), but I don't understand where the rest of the equation was derived from. Can someone explain how this equation is able to answer the above question?

## closed as off-topic by Michael Chernick, Peter Flom♦Apr 29 '18 at 13:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Self-study questions (including textbook exercises, old exam papers, and homework) that seek to understand the concepts are welcome, but those that demand a solution need to indicate clearly at what step help or advice are needed. For help writing a good self-study question, please visit the meta pages." – Peter Flom
If this question can be reworded to fit the rules in the help center, please edit the question.

• You are generating confidence intervals and not intervals that are guarenteed to contain the population mean. – Michael Chernick Apr 29 '18 at 0:44
• This isn't really about R but it is a homework question so it needs the self-study tag and you need to show what you've done so far. – Peter Flom Apr 29 '18 at 13:41

(I probably should put this as a comment, but I'd like to format the equations a bit more precisely.)

The probability of observing a mean of a given sample size $n$ is calculated using the sampling distribution, which is normal with mean $\mu_{\bar{x}}=\mu$ and standard deviation $\sigma_{\bar{x}}=\frac{\sigma}{\sqrt{n}}$. (There are additional requirements here, such as the population distribution needs to be normal, the sample must be randomly drawn, etc.)

So, if we want to find the probability that the sample mean is two more than the population mean, we need to find \begin{align}P(\bar{x} \ge \mu+2) & = P\left( z \ge \frac{(\mu+2)-\mu}{\frac{\sigma}{\sqrt{n}}}\right) \\ & = P\left(z \ge \frac{2\sqrt{n}}{\sigma} \right) \\ & = 1-P\left(z \le \frac{2\sqrt{n}}{\sigma} \right)\\ \end{align}

So, based on the answer provided, it appears the sample size for this problem (which wasn't reported by the OP) is $n=12$.

Lastly, as mentioned by the OP, the value is doubled because the same value is obtained for $P(\bar{x} \le \mu -2)$.

Happy to provide clarification as needed.

• "sample mean estimate is off by more than 2 grams from the population mean" is two-sided, not one-sided as you have done. – Mark L. Stone Apr 29 '18 at 0:42
• yes...I forgot to mention that at the end...will update my answer – Gregg H Apr 29 '18 at 1:41
• This makes a lot more sense, thanks very much. However, I don't understand why the variable z with the operators >= and <= were included in your formula. Could you clarify on that? – talker90 Apr 29 '18 at 19:18
• For a continuous distribution like the normal distribution, $P(z \leq z_0) = P(z < z_0)$ (same for the other inequality direction). – Gregg H Apr 29 '18 at 20:47