Sample Size Calculation
1 | import scipy.stats as stats |
2 | |
3 | def sample_size_calculation(mu, sigma, MDE, alpha=0.05, beta=0.2): |
4 | return 2 * (sigma**2) * ((stats.norm.ppf(1-alpha/2) + stats.norm.ppf(1-beta))**2) / ((mu * MDE)**2) |
5 |
Minimum Defective Effect
1 | from scipy.stats import norm |
2 | |
3 | sample_size = 1000 |
4 | alpha = 0.05 |
5 | z = norm.isf(alpha / 2) |
6 | estimated_variance = ds.y.var() |
7 | detectable_effect_size = z * np.sqrt(2 * estimated_variance / sample_size) |