Hypothesis testing and experiment results
Define a comparison, apply an independent-samples test, and read the result with an effect size.
On this page
Specify the question before testing
Write the null hypothesis, alternative, metric, and threshold before looking at results. A p-value describes how unusual the result is under the null and test assumptions. Report the effect size and uncertainty alongside the p-value. For A/B tests, use the randomization unit and account for repeated measurements.
Compare two independent means
Welch’s t-test compares means from two independent groups without assuming equal variances. Start with a meaningful measurement, independent units, and a suitable sampling design. For the same units measured twice, use a paired analysis. A small p-value does not tell you whether the improvement matters to the business.
import numpy as np
from scipy.stats import ttest_ind
old = np.array([11, 12, 10, 14, 13, 12])
new = np.array([15, 16, 14, 18, 17, 16])
result = ttest_ind(new, old, equal_var=False)
print(f"Difference: {new.mean() - old.mean():.1f}")
print(f"p-value: {result.pvalue:.4f}")
Example output
Difference: 4.0 p-value: 0.0006