A cautionary simulation about selecting on the outcome.
For each of trials repetitions:
n values from , so the null hypothesis is truealphaReturn the fraction of repetitions that rejected. Under a correct procedure this
would sit near alpha; filtering on the sample's own mean is what breaks it.
Seed np.random.seed(seed) inside solve, immediately before drawing.
Input
n = 20
trials = 400
alpha = 0.05
seed = 0
Output
0.815