How would you select representative sample of search queries from 5 million queries?

n = (Z² * p * q) / E²

Rahul S
3 min readApr 19, 2023

SAMPLE SIZE FORMULA

Selecting a sample size is an important step in designing a study or survey. The sample size should be large enough to provide reliable and accurate results, but not so large that it becomes impractical or expensive to collect data. There are different methods to determine the appropriate sample size, but one of the most commonly used formulas is the one for sample size estimation in a survey or study.

The formula to calculate the sample size is:

n = (Z² * p * q) / E²

where:

n = the sample size needed
Z = the z-score (or standard deviation) corresponding to the desired level of confidence (e.g. 1.96 for a 95% confidence level)
p = the proportion of the population that has a certain characteristic or outcome (e.g. the proportion of people who prefer a certain brand)
q = 1 — p (the proportion of the population that does not have the characteristic or outcome)
E = the margin of error (the maximum amount of error that can be tolerated in the sample estimate)

--

--