How to Calculate n Value (Sample Size)
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
This calculator works out the sample size (n) needed for a survey or experiment when you know your desired confidence level, margin of error, and an estimate of the population proportion. You enter those three values, and it returns the minimum number of responses or observations required. It uses the standard formula for estimating a proportion with a finite population correction option.
Formula
The basic formula for sample size when estimating a proportion is:
n = (Z² × p × (1 − p)) / E²
Where:
- n = required sample size (number of people or items)
- Z = Z-score corresponding to your desired confidence level (e.g., 1.96 for 95% confidence)
- p = estimated proportion of the population that has the attribute you’re measuring (0 to 1)
- E = margin of error you can tolerate (as a decimal, e.g., 0.05 for ±5%)
If your population is small (say, under 10,000) and you know its exact size, use the finite population correction:
n_finite = (Z² × p × (1 − p) × N) / (E² × (N − 1) + Z² × p × (1 − p))
Where N is the total population size.
Worked Example
Using the default values: Z = 1.96 (95% confidence), p = 0.5 (worst-case proportion), E = 0.05 (±5%), N = 10,000.
Step 1: Calculate the numerator of the basic formula: Z² × p × (1 − p) = 1.96² × 0.5 × 0.5 = 3.8416 × 0.25 = 0.9604
Step 2: Divide by E²: 0.9604 / 0.05² = 0.9604 / 0.0025 = 384.16
Step 3: Round up to the nearest whole number: n = 385
Step 4: For the finite population version, plug into the formula: (0.9604 × 10,000) / (0.0025 × 9,999 + 0.9604) = 9604 / (24.9975 + 0.9604) = 9604 / 25.9579 ≈ 370.0, round up to 370.
So with a population of 10,000, you need 370 responses; if the population is very large, you need 385.
When to Use This
Use this calculator when planning a survey, a poll, or any experiment where you need to know how many people to include to get a reliable estimate. It’s most commonly used in market research, social science studies, and quality control. The result tells you the minimum sample size—collecting fewer responses risks a wider margin of error than you specified, while collecting more gives you extra precision but costs more time and money.
How to Read the Result
The main output (n) is the number of completed responses you need. If you expect some people not to respond, you’ll need to invite more than this number. The finite population version (n_finite) is lower because when the population is small, sampling a large fraction of it gives you more information per person. Always round up to the next whole number—you can’t survey 384.16 people.
Common Mistakes
- Using percentages instead of decimals. If your margin of error is 5%, you must enter 0.05, not 5. The same goes for the proportion p: 50% becomes 0.5.
- Using the wrong Z-score. A 90% confidence level uses Z = 1.645, 95% uses 1.96, and 99% uses 2.576. Using 1.96 for a 90% level will overestimate your sample size.
- Choosing p = 0.5 when you have a better estimate. p = 0.5 gives the largest sample size (the most conservative). If you know the proportion is around 0.2, using 0.5 wastes resources.
- Forgetting to round up. Always round up to the next whole number, not to the nearest.
- Applying the finite population correction to a large population. If N is over 10,000 or so, the correction barely changes the result—you can skip it.
Tips
- If you don’t know p, use 0.5. It’s the safest choice because it maximizes the required sample size, ensuring your margin of error is at least as good as you asked for.
- Decide your margin of error based on how precise you need the answer. For a political poll, ±3% is common; for a quick customer satisfaction survey, ±5% might be fine.
- If your population is small (under 1,000), always use the finite population correction—it can cut the required sample size substantially.
- Remember that this formula assumes a simple random sample. If you use a different sampling method (e.g., stratified or cluster), the sample size may need to be adjusted.
Troubleshooting
My result seems too large. Check that your margin of error is a decimal (0.05 not 5) and that your confidence level’s Z-score is correct. If you’re using 99% confidence with a 1% margin, a huge sample is expected.
My result seems too small. Make sure you didn’t enter p = 0 or p = 1, which would make the product p(1−p) zero. Also verify that your population size isn’t extremely small (like 50), which legitimately reduces the needed sample.
I get an error or a negative number. Check that all inputs are positive numbers. The margin of error must be greater than 0 and less than 1 (or 100% if you’re thinking in percentages). The proportion p must be between 0 and 1.
I’m not sure what Z-score to use. Common values: 90% → 1.645, 95% → 1.96, 99% → 2.576. If you need another level, look up a Z-table or use a statistical calculator.
Frequently Asked Questions
What is the ‘n value’ in statistics? The n value is the sample size—the number of observations or individuals in a study. It’s a fundamental part of any statistical analysis because it affects the precision of estimates and the power of hypothesis tests.
Why do I need a sample size at all? You can’t survey everyone, so you take a subset. The sample size determines how close your estimate is likely to be to the true population value. Too small a sample gives unreliable results; too large wastes resources.
What happens if I use a smaller sample than calculated? Your actual margin of error will be larger than you planned. For example, if you needed 385 for ±5% but only get 200, your margin might be around ±7%, making your results less precise.
Can I use this for a population of 100? Yes, but you should use the finite population correction. With N=100, p=0.5, and E=0.05, the required sample is about 80, which is much less than 385.
Does this work for continuous data (like averages)? No, this formula is for proportions (yes/no, percentages). For means, you need a different formula that includes the standard deviation of the population.
What if my survey has a non-response rate? Divide the calculated sample size by the expected response rate. For example, if you need 385 and expect a 50% response rate, you should invite 770 people.
Related
Formula used
in z | Z-score (from confidence level) | - | 1.96 | 0 in p | Estimated proportion (0 to 1) | - | 0.5 | 0 in e | Margin of error (as decimal) | - | 0.05 | 0 in N | Population size (leave blank if unknown) | - | 10000 | 0 out n | Required sample size | people | ceil((z^2 * p * (1-p)) / e^2) | 0 out n_finite | Sample size (finite population) | people | ceil((z^2 * p * (1-p) * N) / (e^2 * (N-1) + z^2 * p * (1-p))) | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.