⭐ Starlight Tools / Sample Size Calculator

Sample Size Calculator (Basic)

Calculate the minimum sample size needed for comparing two groups (e.g., A/B testing).

(e.g., 0.80 for 80% power)
(e.g., 0.05 for 5% significance)
(e.g., 0.5 unit difference)
(e.g., 1.0 unit SD)
Result:

Understanding Sample Size Calculation

A Sample Size Calculator is crucial for designing experiments (like A/B tests, clinical trials, or surveys) to ensure that your study has enough participants to detect a statistically significant difference if one truly exists, without wasting resources on an overly large sample.

Key Concepts:

  • Statistical Power $(1 - \beta)$: The probability that your study will detect a true effect if there is one. Commonly set at 0.80 (80%). Higher power requires a larger sample size.
  • Significance Level $(\alpha)$: The probability of rejecting a true null hypothesis (Type I error, or false positive). Commonly set at 0.05 (5%). A smaller $\alpha$ requires a larger sample size.
  • Effect Size $(\delta$ or Difference in Means): The minimum difference between the means of the two groups that you consider practically significant and want to detect.
  • Standard Deviation $(\sigma)$: A measure of the spread or variability of data within each group. This is typically estimated from previous studies, pilot data, or domain knowledge. Higher variability requires a larger sample size.

How This Tool Works:

This calculator uses a common formula for determining the sample size per group for an independent two-sample t-test (comparing the means of two groups), assuming equal group sizes and variances. It is based on power analysis principles and the normal distribution approximation.

The formula for sample size ($n$) per group is approximately:

$$ n = \frac{2(Z_{1-\alpha/2} + Z_{1-\beta})^2 \sigma^2}{\delta^2} $$

Where:

  • $n$ is the required sample size per group.
  • $Z_{1-\alpha/2}$ is the Z-score corresponding to the desired significance level (for a two-tailed test). For $\alpha = 0.05$, $Z_{1-\alpha/2} = Z_{0.975} = 1.96$.
  • $Z_{1-\beta}$ is the Z-score corresponding to the desired power. For Power $= 0.80$, $Z_{1-\beta} = Z_{0.80} = 0.842$.
  • $\sigma$ is the estimated standard deviation of the population.
  • $\delta$ is the estimated effect size (the minimum difference between means you wish to detect).

Alternatively, the formula can be expressed using Cohen's $d = \frac{\delta}{\sigma}$ (the standardized effect size):

$$ n = \frac{2(Z_{1-\alpha/2} + Z_{1-\beta})^2}{d^2} $$

This tool takes your estimated difference in means $(\delta)$ and estimated standard deviation $(\sigma)$ to internally calculate Cohen's $d$, and then applies the formula to determine the required sample size per group.