All problems
Optional Stopping Inflation (Seeded)
Problem
Optional stopping can inflate the largest z-score. Estimate E[max of n independent standard normal variables] by simulation: for each of trials experiments draw n standard normals with a seeded Box-Muller transform and average the maximum. Return 0.0 for n <= 0 or trials <= 0.
Hint
Use 1 - rng.random() in the Box-Muller transform so the logarithm is always defined.
Test cases
case 1
in: [10,2000,42]
expected: 1.5311661530535472
case 2
in: [100,1000,7]
expected: 2.5290880063226346
case 3
in: [1,500,0]
expected: -0.03259471581671577
case 4
in: [0,5,1]
expected: 0
Starter codePython
import math
import random
def max_of_normals_expected_simulation(n, trials, seed):
# Your code here
pass4 test cases · run your code against them in the editor