Skip to content
DeepForgeby svx
All problems
HardStatisticsst-262

Minimum Detectable Effect

Problem

Return the minimum detectable effect for a two-sided test: (z(1 - alpha/2) + z(power)) * sqrt(2 * variance / n), where z is the standard normal quantile obtained by bisecting the normal CDF. Return 0.0 when n <= 0, variance <= 0, or alpha or power lie outside (0, 1).

Hint

Bisect the normal CDF, which is 0.5 * (1 + erf(x / sqrt(2))).

Test cases

case 1
in: [100,0.25,0.05,0.8]
expected: 0.19810199057996716
case 2
in: [400,1,0.05,0.9]
expected: 0.22920976267865004
case 3
in: [0,1,0.05,0.8]
expected: 0
case 4
in: [100,0,0.05,0.8]
expected: 0
Starter codePython
import math
def minimum_detectable_effect(n, variance, alpha, power):
    # Your code here
    pass

4 test cases · run your code against them in the editor