# Calculating the size of a sample from confidence interval

Working on some math for school I came across the following exercise:

John is examining how large a proportion of the population want to buy a
newly released phone model. The answers are given as the confidence interval
(0.3, 0.42) which has the confidence level 0.95. How many persons (n) were


According to the book, for a confidence level of 0.95 I should use the following formula to calculate the sample size:

$\bar{z}+1.96{\sigma \over \sqrt{n}}-(\bar{z}-1.96{\sigma \over \sqrt{n}})$

$\bar{z}+1.96{\sigma \over \sqrt{n}}-\bar{z}+1.96{\sigma \over \sqrt{n}} = 3.92{\sigma \over \sqrt{n}}$

This makes sense. As I am not given the standard deviation, I calculate it as suggested in this answer on roughly the same topic. I get

$\sigma = \sqrt{0.3(1-0.3)}\approx 0.46$

So I enter this into the expression and get

${{3.92*0.46} \over \sqrt{n}} = {1.56 \over \sqrt{n}}$

Now this is where it all falls apart for me. According to the book I should now set the above expression to be equal to the maximum length of the interval, and then calculate n from there, which makes sense. But I was never given an interval length. So how do I procede?

(Looking at the answer tells me that $n=246$, which gives the length $l\approx 0.01$, but as I can't use this in my calculations it doesn't really help me.)

• $3.92\times 0.46=1.8032 \not = 1.56$ Oct 22, 2015 at 16:13
• The confidence interval length is $0.42-0.3=0.12$ Oct 22, 2015 at 16:14
• @Henry Of course, thanks! I accidentally entered $3.42*0.46$ instead of $3.92*0.46$.. Thanks for pointing that out! Oct 22, 2015 at 16:38

You are probably expected to use the mid-point of the confidence interval $\frac{0.3+0.42}{2} = 0.36$. This would make $\sigma=\sqrt{0.36(1-0.36)}=0.48$.
The length of the confidence interval should then be $2 \times 1.96 \times \frac{0.48}{\sqrt{n}}$. But the length of the confidence interval is in fact $0.42-0.3=0.12$.
Solving this gives $n \approx 245.86$ and rounding to an integer gives $246$.
You have the confidence interval $$\left[\bar{z} - 1.96 \frac{\sigma}{\sqrt{n}}, \bar{z} + 1.96 \frac{\sigma}{\sqrt{n}}\right]$$ The length from this interval is the upper end minus the lower end $$\bar{z} + 1.96 \frac{\sigma}{\sqrt{n}} - \left( \bar{z} - 1.96 \frac{\sigma}{\sqrt{n}} \right) = 2 \cdot 1.96 \frac{\sigma}{\sqrt{n}}$$ Now you know the length of the given confidence interval is 0.12. With this you can compute $$2\cdot 1.96 \frac{\sigma}{\sqrt{n}} = 0.12$$ and this is the case when $$\left(\frac{3.92 \cdot \sigma}{0.12}\right)^2 \geq n$$