Distributions under H₀ and H₁
Where the sample result falls if H₀ is true (blue) and if the difference is real (red). The shaded regions represent the probabilities of each type of error and the power of the test.
How this tool works, step by step
Unlike other ProbLab simulators, this one does not draw random samples: it computes α, β and the power with exact formulas and plots them, so the result is always the same for the same values. The model is the one-mean z-test: a decision between H₀: μ = μ₀ and the alternative, based on the mean of n observations with standard deviation σ.
- The sample is summarised in one number. The statistic \(Z = (\bar{x} - \mu_0)/(\sigma/\sqrt{n})\) measures how many standard errors the sample mean is from μ₀. It is the horizontal axis of the chart.
- Blue curve: what would happen if H₀ were true. In that case Z follows a standard normal, centred at 0.
- Red curve: what would happen if the difference were real. If the true mean is as far from μ₀ as the slider says, Z follows a normal with the same shape but shifted to δ = d × √n. That distance is the "Separation between curves" card.
- The level α sets the boundary. The dashed vertical line is the critical value: zα in the one-tailed test and ±zα/2 in the two-tailed test. H₀ is rejected when Z falls beyond it.
- The areas are the probabilities. The red area is the part of the blue curve that lies in the rejection region: α. The grey area is the part of the red curve that lies in the non-rejection region: β. The green area is the rest of the red curve: the power, 1 − β.
Each control changes one thing. The true difference and the sample size pull the two curves apart, without moving the boundary. The level α moves the boundary, without moving the curves. The type of test decides whether there is one boundary or two.
With the standard deviation σ (optional), everything is read in the units of your data: the difference is shown as Δ = d × σ, and the axis and the boundaries become values of the sample mean, \(\mu_0 + z \cdot \sigma/\sqrt{n}\). The probabilities do not change: it is the same chart on another scale. For example, with σ = 8 g and n = 30, the standard error is 8/√30 = 1.46 g; a true difference of 4 g corresponds to d = 0.5 and separates the curves by 4/1.46 = 2.74 standard errors.
If you arrive from a ProbLab test, the fields are filled in with your α, your n and the smallest difference that test detects with 80% probability; that is why the power you see is around 80%.
Where the formulas for β and power come from
Starting point: the distribution of the sample mean
If the observations have mean μ and standard deviation σ, the mean of n independent observations follows (exactly for normal data, approximately in general, by the central limit theorem) a normal with the same mean and standard deviation σ/√n:
The statistic under H₀ and under H₁
The test statistic subtracts μ₀ and divides by the standard error. Adding and subtracting the true mean μ in the numerator splits it into two parts:
The first part is always a standard normal. The second is a fixed number, which measures the true difference in standard errors:
Therefore \(Z \sim N(\delta,\,1)\). If H₀ is true, μ = μ₀, δ = 0 and you get the blue curve. Otherwise you get the red curve, the same bell shifted by δ units. All of power analysis comes down to that shift.
Right-tailed test
H₀ is rejected when \(Z > z_\alpha\), where \(z_\alpha\) leaves an area α to its right under the standard normal (1.645 for α = 0.05). A type II error is failing to reject when the difference is real, that is, an \(N(\delta, 1)\) falling below \(z_\alpha\). Subtracting δ to standardise:
where Φ is the standard normal distribution function. The power is the complement:
Two-tailed test
Now H₀ is rejected when \(|Z| > z_{\alpha/2}\) (1.960 for α = 0.05), and there are two rejection regions. The power is the sum of the two tails of the \(N(\delta, 1)\):
The second term is the probability of rejecting "on the wrong side" and is almost always negligible. Since \(z_{\alpha/2} > z_\alpha\), the two-tailed test has less power than the one-tailed test for the same difference: that is the price of watching both directions.
From power to sample size
The same formula, read backwards, gives the sample size. For the power to be at least 1 − β you need \(\Phi(\delta - z_\alpha) \ge 1 - \beta\), that is, \(\delta - z_\alpha \ge z_\beta\). Substituting \(\delta = \Delta\sqrt{n}/\sigma\), with Δ = μ − μ₀, and solving for n:
In the two-tailed test, \(z_{\alpha/2}\) replaces \(z_\alpha\). This is the formula behind the sample size calculator for the one-mean test. Two rules follow from it: detecting a difference half as large takes four times as much data, and going from 80% to 90% power takes about a third more.
A worked example
With the tool's initial values, d = 0.5, n = 30 and α = 0.05 one-tailed:
- Separation: \(\delta = 0.5 \times \sqrt{30} = 2.739\).
- Critical value: \(z_{0.05} = 1.645\).
- Type II error: \(\beta = \Phi(1.645 - 2.739)\) \(= \Phi(-1.094) = 0.137\).
- Power: \(1 - 0.137 = 0.863\).
With the two-tailed test, the critical value rises to 1.960 and the power drops to 0.782. Reaching 80% in the one-tailed test would take \(((1.645 + 0.842)/0.5)^2 = 24.7\), that is, 25 observations; in the two-tailed test, 32.
What this model simplifies
The tool treats σ as known. In a real test with unknown σ, Student's t is used and the power is computed with the noncentral t distribution; the result is somewhat lower, especially with small samples (in the example above, 0.848 instead of 0.863). ProbLab's hypothesis test and sample size calculators use the exact computation in each case. The logic, however, is always the one in this chart: two distributions of the statistic, a boundary and the areas on either side.
What are type I and type II errors?
When we run a hypothesis test we make a binary decision: reject the null hypothesis H₀ or fail to reject it. Like any decision based on incomplete information (a sample, not the entire population), this decision can be wrong in two distinct ways, and we call these two ways type I error and type II error.
A type I error occurs when we reject H₀ while it is actually true in the population. The probability of making this error is precisely the significance level α that we fix before running the test. If we set α = 0.05, we are accepting that there is a 5% probability of declaring a significant effect when in fact none exists. This error is also called a false positive or false alarm.
A type II error occurs when we fail to reject H₀ when it is false — that is, when a real effect exists in the population but our test fails to detect it. The probability of making this error is denoted by the letter β and is also called a false negative. Its complement, 1 − β, is the statistical power: the probability that the test correctly detects an effect when one exists.
A useful analogy is a courtroom verdict. Suppose H₀ is "the defendant is innocent." A type I error is equivalent to convicting an innocent person (false positive), while a type II error is equivalent to acquitting a guilty one (false negative). In criminal law, the tradition is to specifically protect against type I errors ("better that a hundred guilty go free than one innocent be convicted"), setting a very high evidentiary bar. In science and medicine, the optimal balance between the two errors depends on the practical consequences of each kind of mistake.
The relationship between α and β is inseparable: holding everything else constant, lowering α (being stricter) increases β (raises the probability of missing real effects), and vice versa. This trade-off is the central dilemma in the design of statistical studies.
| Decision \ Reality | H₀ true | H₀ false (H₁ true) |
|---|---|---|
| Fail to reject H₀ | Correct decision (1 − α) | Type II error (β) |
| Reject H₀ | Type I error (α) | Correct decision: Power (1 − β) |
Statistical power
Statistical power (1 − β) is the probability that a test correctly detects a real effect. It is, in a sense, the "sensitivity" of the test: a high-power test rarely misses effects that truly exist in the population.
In the simulator, power corresponds to the green region under the H₁ curve within the rejection zone. The greater the overlap between the two distributions (H₀ and H₁), the lower the power; the more separated they are, the higher the power. Four factors determine power:
- Effect size (Cohen's d): the real difference between means expressed in units of standard deviation. The larger the effect, the easier it is to detect. An effect of d = 0.2 is considered small, d = 0.5 medium and d = 0.8 large.
- Sample size (n): the factor most easily controlled in the design. As n increases, the standard error of the mean decreases, the distributions become narrower and their overlap shrinks. The non-centrality parameter δ = d × √n jointly captures the effect of the effect size and the sample size.
- Significance level (α): increasing α shifts the rejection region to the left (in a right-tailed test), capturing more area under the H₁ curve and increasing power. In exchange, it raises the false-positive rate.
- Measurement variability (σ): a measure with less noise produces more precise statistics. The simulator works in standardised units (which is why σ does not change the probabilities, only the scale they are read on), but in practice reducing experimental variability (a better protocol, more homogeneous analysis units) directly increases power.
In scientific research and clinical trials it is common to set a minimum target power of 80% (β ≤ 0.20). This means we accept up to a 20% probability of missing a real effect when it exists. Some more demanding fields, such as pivotal pharmacology trials, require power of 90% or even higher.
A frequent and problematic practice is the underpowered study: a study with insufficient power that, if it obtains a significant result, probably did so due to chance (the Ioannidis effect, 2005). Underpowered studies that do detect effects also tend to overestimate the effect size, the so-called winner's curse.
The α vs β trade-off
The tension between the type I error and the type II error is one of the most fundamental problems in statistical inference. With a fixed sample size, it is not possible to minimize both simultaneously: any change in α inevitably affects β in the opposite direction.
To visualize this intuitively: the critical value zα is the point that separates the non-rejection region from the rejection region. Lowering α, for example moving from z0.05 = 1.645 to z0.01 = 2.326, shifts the decision threshold to the right. This shift means the rejection region captures less area of the distribution under H₁, which increases β and reduces power.
The only way to reduce both errors simultaneously is to increase the sample size. As n grows, the two distributions (under H₀ and under H₁) become narrower and more separated, reducing their overlap. This makes it possible to keep α low while also achieving high power.
From a theoretical standpoint, the Neyman-Pearson lemma (1933) establishes that the likelihood-ratio test is the most powerful test of level α for testing simple hypotheses. In other words, given fixed α and n, the likelihood-based test maximizes power — no other test of the same level can outperform it.
In practice, the choice of α depends on context: basic research conventionally uses α = 0.05; exploratory studies may relax it to α = 0.10 to avoid missing potentially interesting findings; applications with high consequences for type I error (medical diagnosis, safety quality control) use much stricter values (α = 0.001 or lower). In any case, the choice should be explicit, justified and set before collecting the data.
When the economic or human consequences of both types of error are quantifiable, statistical decision theory proposes balancing the two errors by weighting their respective costs. If the cost of a false positive is CI and the cost of a false negative is CII, the optimal decision threshold depends on the ratio CI/CII and on the prior prevalence of H₁, which connects to the Bayesian approach to inference.
Frequently asked questions
Why not always use α = 0.001 to be safer?
Using a very small α protects against false positives, but it also drastically increases the type II error (β) for a given sample size. If a real effect exists, a very strict α makes the test so demanding that it rarely reaches the rejection region, producing many false negatives. Moreover, in exploratory research, being too strict can lead to discarding true hypotheses before they can be investigated further. The choice of significance level should balance the cost of the two types of error according to the context of the study.
What is the p-value and how does it relate to α?
The p-value is the probability of obtaining a statistic as extreme as, or more extreme than, the one observed, assuming H₀ is true. It is not the probability that H₀ is true (a very common conceptual mistake). The decision rule is: if p ≤ α, we reject H₀; if p > α, we fail to reject H₀. The significance level α is the pre-set threshold against which we compare the p-value. Therefore, α directly controls the long-run type I error rate: if we apply the rule p ≤ α across many experiments in which H₀ is true, approximately a fraction α of them will produce significant results by chance.
How can I increase power without changing α?
The most direct way is to increase the sample size. The non-centrality parameter δ = d × √n grows with n, separating the distributions under H₀ and H₁ further apart and reducing their overlap. Other strategies include: (1) increasing the expected effect size, designing the study to maximize the difference you want to detect (for example, using higher doses in a clinical trial, if that is ethical and feasible); (2) reducing the variability of measurements through a more rigorous protocol, more precise measurements or a more homogeneous experimental design; (3) using more efficient designs, such as paired or block designs, which remove variability due to known covariates; and (4) performing an a priori power analysis to determine the required n before starting the study.
What is Cohen's effect size?
Cohen's d is the difference between two means expressed in units of standard deviation. Formally, d = (μ₁ − μ₀) / σ, where σ is the common standard deviation of the populations. This standardization allows effects to be compared across studies with different measurement scales. Jacob Cohen (1988) proposed the thresholds d = 0.2 (small effect), d = 0.5 (medium effect) and d = 0.8 (large effect). However, these thresholds are only a guide and should not be applied mechanically: an effect of d = 0.2 can be highly relevant in preventive medicine (if it affects millions of people) and irrelevant in experimental psychology. Effect size should always be interpreted in the substantive context of the research.
References and further reading
- Type I and type II errors — Wikipedia. Definitions and examples.
- Power (statistics) — Wikipedia. Power, the factors that determine it and a priori analysis.
- Neyman, J. and Pearson, E. S. (1933). On the problem of the most efficient tests of statistical hypotheses. Philosophical Transactions of the Royal Society A, 231, 289–337. The paper that introduces the two types of error and the Neyman-Pearson lemma.
- Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.). Lawrence Erlbaum. The reference book on power and effect sizes.
- Cohen, J. (1992). A power primer. Psychological Bulletin, 112(1), 155–159. A short, practical summary, with the thresholds for small, medium and large effects.
- Ioannidis, J. P. A. (2005). Why most published research findings are false. PLoS Medicine, 2(8), e124.
- Button, K. S. et al. (2013). Power failure: why small sample size undermines the reliability of neuroscience. Nature Reviews Neuroscience, 14, 365–376. The consequences of working with underpowered studies.