File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -385,12 +385,16 @@ Simulations::
385385
386386 >>> # Estimate the probability of getting 5 or more heads from 7 spins
387387 >>> # of a biased coin that settles on heads 60% of the time.
388- >>> trial = lambda: choices('HT', cum_weights=(0.60, 1.00), k=7).count('H') >= 5
388+ >>> def trial():
389+ ... return choices('HT', cum_weights=(0.60, 1.00), k=7).count('H') >= 5
390+ ...
389391 >>> sum(trial() for i in range(10000)) / 10000
390392 0.4169
391393
392394 >>> # Probability of the median of 5 samples being in middle two quartiles
393- >>> trial = lambda : 2500 <= sorted(choices(range(10000), k=5))[2] < 7500
395+ >>> def trial():
396+ ... return 2500 <= sorted(choices(range(10000), k=5))[2] < 7500
397+ ...
394398 >>> sum(trial() for i in range(10000)) / 10000
395399 0.7958
396400
You can’t perform that action at this time.
0 commit comments