How can I calculate the sample mean and sample standard deviation, given that I know the sample size and the confidence interval for the mean?
For example, with the info provided below:
- Sample size = 300
- 95% confidence interval of 5.18 < μ < 5.38
Obviously you will need to know the type of confidence interval you are dealing with, but let's suppose that this is a standard one-sample confidence interval for the mean, using the standard T-statistic as the pivotal quantity. In that case, the formula for the interval is:
$$\text{CI}(1-\alpha) = \Bigg[ \bar{x} \pm \frac{t_{n-1, \alpha/2}}{\sqrt{n}} \cdot s \Bigg].$$
Thus, if we denote the known lower and upper bounds of the interval as $l$ and $u$ respectively, then you can algebraically reverse-engineer the sample mean and sample standard deviation as:
$$\bar{x} = \frac{l+u}{2} \quad \quad \quad \quad \quad s = \frac{u-l}{2} \cdot \frac{\sqrt{n}}{t_{n-1, \alpha/2}}.$$
With the values specified in your example, you get:
#Set preliminary values
l <- 5.18;
u <- 5.38;
n <- 300;
alpha <- 0.05;
#Compute sample mean and SD
crit <- qt(alpha/2, df = n-1, lower.tail = FALSE);
MEAN <- (l+u)/2;
SD <- (u-l)*sqrt(n)/(2*crit);
#Print the values
MEAN;
[1] 5.28
SD;
[1] 0.8801386
Thus, assuming that your interval was a standard one-sample confidence interval, you must have had a sample mean $\bar{x} = 5.28$ and sample standard deviation $s = 0.88$.