# Sample size calculator

Calculates the sample size for a survey (proportion) or calculates the sample size for a normal confidence interval.

Fill in the proportion , or the Standard deviation (σ).

.
To get the confidence interval of Estimate value ± MOE
Leave empty for an infinite population. When the sample size is less than 5% of the entire population you can assume an infinite population.

## What is the sample size?

The sample size is the number of observations in research, study, experiment, or survey. For example, the number of subjects participating in the research
A sample is only a subset of subjects from the entire population.

## Sample size formula

##### Sample size formula when using the population standard deviation (S)
 n = ( Z1-α/2 * σ ) 2 MOE

Since Z is symmetrical, you may use Zα/2 or Z1 - α/2.

##### Sample size formula when using the sample standard deviation (σ)
 n = ( t(n-1)1-α/2 * S ) 2 MOE

Since n appears also in t(n-1), we run several iterations until finding the smaller sample size that results in MOE that is smaller or equal to the defined MOE:

 MOE = t(n-1)1-α/2 * S √n

n - sample size.
Z1-α/2 - Z score from the standard normal distribution.
t1-α/2 - t score from the t distribution.
σ - the population standard deviation, you use it when you know it before the research.
S - the sample standard deviation, you use it when you don't know it before the research.
MOE - Margin Of Error, half-width of the confidence interval, for a smaller MOE mean, narrower confidence interval, you need a larger sample size.
CL - the Confidence Level is the required degree of certainty that the population parameter will be in the confidence interval.
α the error: α = 1 - CL.

### Is a larger sample size better?

From a statistical point of view, larger sample size is better, with a smaller margin of error.
Usually, a larger sample size costs more and takes more time to gather. Sometimes you even need to destroy each unit in the sample to get the result.

Example
What sample size should you use for a survey in a city with a population of 120,000 people?
You want to have a confidence level of 0.95 (95%).
The confidence interval should be ± 0.04.
Survey question: "what party will you vote?"

Solution
Confidence level = 0.95 .
If you don't know what proportions to expect you should assume the worth case meaning the largest standard deviation.
Proportion = 0.5
The largest standard deviation for a proportion is for proportion = 0.5, which means that one party will gain 50% of the votes.
Population standard deviation (σ)
- leave empty, the standard deviation will be calculated from the proportion.
Margin of error (MOE) = 0.04 .
Population (N) = 120,000 .