Sample Size Calculator for Research Formula
Understand the math behind the sample size calculator for research. Each variable explained with a worked example.
Formulas Used
Required Sample Size
sample_size = ceil(n_infinite / (1 + (n_infinite - 1) / population))Sample (Infinite Population)
n_before_correction = ceil(n_infinite)Variables
| Variable | Description | Default |
|---|---|---|
confidence_z | Z-Score for Confidence Level | 1.96 |
margin_of_error | Margin of Error | 0.05 |
proportion | Expected Proportion | 0.5 |
population | Population Size | 10000 |
n_infinite | Derived value= pow(confidence_z, 2) * proportion * (1 - proportion) / pow(margin_of_error, 2) | calculated |
How It Works
How to Calculate Sample Size
The sample size formula balances precision against cost. A larger sample reduces the margin of error but requires more resources.
Formula (Cochran's)
n_0 = Z^2 x p x (1 - p) / E^2
With finite population correction:
n = n_0 / (1 + (n_0 - 1) / N)
Where Z is the z-score for your confidence level, p is the expected proportion, E is margin of error, and N is population size.
Using p = 0.5 gives the most conservative (largest) sample size when the true proportion is unknown.
Worked Example
A researcher needs 95% confidence (Z = 1.96), 5% margin of error, expected proportion 0.5, population 10,000.
- 01n_0 = 1.96^2 x 0.5 x 0.5 / 0.05^2 = 3.8416 x 0.25 / 0.0025 = 384.16
- 02Finite correction: 384.16 / (1 + 383.16 / 10000) = 384.16 / 1.0383 = 370
- 03Required sample size: 370
Frequently Asked Questions
Why use 0.5 for proportion?
When you do not know the expected proportion, 0.5 maximizes the variance (p x (1-p)), giving the most conservative sample size.
What if my population is very large?
For very large populations, the finite correction has minimal effect and the sample size approaches the infinite-population formula.
How does confidence level affect sample size?
Higher confidence requires a larger sample. Going from 95% to 99% confidence increases sample size by about 75%.
Ready to run the numbers?
Open Sample Size Calculator for Research