MECHOWL QUALITY ANALYSIS AI
Sample Size and Power Calculator for t-Tests and Tests of Defect Rates
From the difference to find, the spread (or the defect rates), the significance level and the power, get the sample size a t-test (two-sample, paired or one-sample) or a test of defect rates needs. The power of a given number can be computed too, and the standard deviation can come from pasted past data.
Last updated
Your data is not sent. Everything is computed in your browser
Data
The data box is optional. When estimating the number for a t-test without entering the standard deviation, paste past measurements as one column and their standard deviation is used. For defect rates, the data box is not used.
Read 20 rows and 1 columns.
More settings (Chart title)
Empty: "Sample size (test)".
Judgement rules
Decide the significance level and the alternative hypothesis before looking at the data. If you change them, write it in the report.
The probability of a significant result when the difference is real. Usually 0.8 (80 %) or 0.9.
The default is a common guideline (see —).
Two-sided is the usual choice. One-sided only when the direction is fixed in advance (it needs a smaller number).
The default is a common guideline (see —).
Usually 0.05.
The default is a common guideline (see —).
Result
Required: 17 (per group)
Result of the sample data
Required: 17 (per group)
Computed for the two-sample t-test (two-sided, significance level 0.05).
- Required: sample size per group n
- 17
- Power at that number
- 81.1 %
About the data
- Method: non-central t distribution (exact, from the degrees of freedom and the non-centrality).
How to read it
What the chart shows
- To find a difference of 0.005 (1.006 times the standard deviation 0.004972) with a two-sample t-test at 80 % power, you need 17 (per group, the same in both groups; 34 in total). The power at that number is 81.1 %.
- The standard deviation is 0.004972, from the 20 past values in the data box.
Common misreadings
- This is the number of data a hypothesis test needs to find a difference. It is not the sample size of acceptance sampling (the number taken from a lot to accept or reject it).
- If the standard deviation is larger than estimated, more data are needed (the number grows with the square of the standard deviation). With little past data, allow a margin.
- A power of 80 % means that even when the difference is real, it is missed (not significant) once in five times. Use 90 % when a miss is costly.
Next steps
- Once you have this number of data, compare them with the t-test (decide the number before collecting the data, and do not add data on the way).
Numbers
| Required: sample size per group n | 17 |
|---|---|
| Total (both groups) | 34 |
| Power at that number | 81.1 % |
| Computed number (before rounding up to an integer) | 16.54 |
| Effect size (difference ÷ standard deviation) d | 1.0056 |
| Standard deviation (from the past data) | 0.004972 |
Calculation steps
- Effect size
d = difference to find ÷ standard deviation0.005 ÷ 0.004972 = 1.0056 - Power
degrees of freedom ν = 2n − 2, non-centrality λ = d × √(n/2), 1 − β = P(T′ > t(1 − α/2, ν)) (T′: non-central t distribution) (two-sided: the probability on the opposite side is added)n = 17 → 81.13 % - Required number
the smallest integer whose power reaches the targetcomputed 16.542 → 17 (target 80 %)
Sample size and power
| Sample size per group | Power |
|---|---|
| 2 | 9.6 % |
| 3 | 16.0 % |
| 4 | 22.5 % |
| 5 | 28.9 % |
| 6 | 35.1 % |
| 7 | 41.0 % |
| 8 | 46.5 % |
| 9 | 51.8 % |
| 10 | 56.7 % |
| 11 | 61.2 % |
| 12 | 65.3 % |
| 13 | 69.2 % |
| 14 | 72.6 % |
| 15 | 75.8 % |
| 16 | 78.6 % |
| 17 | 81.1 % |
| 18 | 83.4 % |
| 19 | 85.4 % |
| 20 | 87.3 % |
| 21 | 88.9 % |
| 22 | 90.3 % |
| 23 | 91.5 % |
| 24 | 92.6 % |
| 25 | 93.6 % |
| 26 | 94.5 % |
| 27 | 95.2 % |
| 28 | 95.9 % |
| 29 | 96.4 % |
| 30 | 96.9 % |
| 31 | 97.3 % |
The results are reference values based on the data you entered and the formulas and criteria shown. They are not a quality guarantee or a pass/fail decision. The final decision rests with you.
References
- NIST/SEMATECH e-Handbook of Statistical Methods, 7.2.2.2 Sample sizes required (for the mean) · NIST · Open
- NIST/SEMATECH e-Handbook of Statistical Methods, 7.2.4.2 Sample sizes required (for the proportion of defectives) · NIST · Open
- JIS Z 8101-2:2015 Statistics — Vocabulary and symbols — Part 2: Applied statistics (in Japanese) · Japanese Standards Association (JSA)
Standards are shown by number and title only.
Sample size explained
The required sample size is the number of data a hypothesis test needs to find a difference of a given size with a chosen probability (the statistical power, usually 80 %). The smaller the difference and the larger the spread, the more data are needed. A power analysis like this is not the same as the sample size of acceptance sampling, the number of items taken from a lot to accept or reject it.
Sample size: how to calculate it by hand
- Choose the test (t-test or test of defect rates), the significance level α (usually 0.05) and the target power (usually 0.8).
- Decide the difference you do not want to miss in practice (a difference of means, or the current defect rate and the rate to find).
- For a t-test, estimate the spread (standard deviation) from past data and compute the effect size d = difference ÷ standard deviation.
- Compute the power while increasing n one by one; the smallest n whose power reaches the target is the required sample size (the non-central t distribution for t-tests, the normal approximation for defect rates).
Worked examples
Example 1: Two samples, a difference of half a standard deviation (d = 0.5, power 80 %)
The data box is not used: the result comes from the settings alone.
Settings: Test = Two-sample t-test (difference of means), Difference to find (t-test) = 0.5, Standard deviation (t-test) = 1
Effect size d = 0.5 ÷ 1 = 0.5. With n per group, the degrees of freedom are 2n − 2 and the non-centrality is 0.5 × √(n/2). n = 63 gives a power of 79.6 % and n = 64 gives 80.15 % → 64 per group (128 in total). Slightly more than the normal approximation n ≈ 2(z₀.₉₇₅ + z₀.₈)²/d² = 2 × (1.960 + 0.842)²/0.25 = 62.8 (because of the t distribution).
Example 2: One sample, one-sided, a difference of one standard deviation (NIST example)
The data box is not used: the result comes from the settings alone.
Settings: Test = One-sample t-test (against a reference), Difference to find (t-test) = 1, Standard deviation (t-test) = 1, Alternative hypothesis = One-sided (greater or higher), Target power = 0.9
The example of NIST/SEMATECH e-Handbook 7.2.2.2: α = 0.05 (one-sided), β = 0.10, a difference of one standard deviation. The normal approximation gives (1.645 + 1.282)² = 8.57 → 9, and iterating with the t distribution gives 11. This page uses the non-central t distribution: computed 10.08 → 11 (power 92.4 % at that number).
Example 3: One defect rate, finding a change from 10 % to 20 % (NIST example)
The data box is not used: the result comes from the settings alone.
Settings: Test = Test of one defect rate (against a target), Current or reference defect rate (rates) = 10, Defect rate to find (rates) = 20, Alternative hypothesis = One-sided (greater or higher), Target power = 0.9
The example of NIST/SEMATECH e-Handbook 7.2.4.2: N ≥ ((1.645 × √(0.1 × 0.9) + 1.282 × √(0.2 × 0.8)) / 0.10)² ≈ 102 (101.27 with the three-digit z values NIST shows). This page does not round z: 101.22 → 102.
Example 4: Power of a given number, two defect rates (5 % and 10 %, 300 each)
The data box is not used: the result comes from the settings alone.
Settings: Test = Test of two defect rates, Current or reference defect rate (rates) = 5, Defect rate to find (rates) = 10, Solve for = Power of a given number, Number (when solving for power) = 300
p̄ = 0.075, σ₀ = √(2 × 0.075 × 0.925 / 300) = 0.021506, σ₁ = √((0.05 × 0.95 + 0.10 × 0.90)/300) = 0.021409. Power = Φ((0.05 − 1.96 × 0.021506)/0.021409) + Φ((−0.05 − 1.96 × 0.021506)/0.021409) = 0.6431 (300 per group gives 64 %, short of the target of 80 %).
Example 5: The rate to find equals the current rate (difference 0)
The data box is not used: the result comes from the settings alone.
Settings: Test = Test of two defect rates, Current or reference defect rate (rates) = 5, Defect rate to find (rates) = 5
With a difference of 0, the power stays at the significance level however much data are added. The page asks for a difference to find.
Example 6: Target power of 1 or more (input error)
The data box is not used: the result comes from the settings alone.
Settings: Test = Two-sample t-test (difference of means), Difference to find (t-test) = 1, Standard deviation (t-test) = 1, Target power = 1
A power of 1 (100 %) cannot be reached with a finite number of data. The page asks for a value greater than the significance level and less than 1.
Common mistakes
- Adding data after a result that was not significant (the significance level no longer holds; decide the number before collecting the data).
- Setting the difference to find "small, just in case" (the number needed becomes very large; use the size of difference that matters in practice).
- Confusing it with the sample size of acceptance sampling (the number that decides whether a lot is accepted).
FAQ
- Is this the same as the sample size of acceptance sampling?
- No. The sample size of acceptance sampling is the number taken to accept or reject a lot, decided from the sampling plan (its OC curve). This page gives the number of data a hypothesis test needs to find a difference, for example between two groups.
- What does a power of 80 % mean?
- When a difference of the size you want to find really exists, the test is significant 8 times out of 10. The remaining 20 % is the probability of missing a real difference (the type II error β). The significance level α is the probability of a significant result when there is no difference (the type I error).
- Is my data sent anywhere?
- No. The calculations and the chart are made in your browser only.
Scope
The required sample size and the power of t-tests (two samples with the same number in both groups, paired samples, one sample) and of tests of defect rates (two groups of the same size, or one rate).
Not covered by this tool:
- Groups of different sizes, and the power of analysis of variance or regression.
- The sample size of acceptance sampling (OC curves).
Excel template: Sample size
A template with the column names and sample values only (no formulas). Enter your values, then copy the range and paste it into the box above.