Question: Python 3, please include doc strings and sample I/O. Basically, the simulation is that you have three doors (1,2,3) - 1/3 || 33% odds of





Python 3, please include doc strings and sample I/O.
Basically, the simulation is that you have three doors (1,2,3) - 1/3 || 33% odds of winning. If you pick the correct door, you win.
If you pick the wrong door, you may open a second door at random (now 1,2,3; omitting whatever door was opened previously) - 1/2 || 50% odds of winning.
def montyDoor = Initial choice (1-3 at random, equal odds); chance it is correct. If incorrect, answer is apended.
def otherDoor = New doors (with MontyDoor apended).
def experimentMonty = three "styles"; one will not pick new doors, one will always pick a new door, and one will choose at random (50% new door, 50% not).
Three results, three winsot wins (bool - true/false)
def trialMonty = repeat experimentMonty 1000 times for each option (always new door, never door, 50% new door)
def MCMonty = based on 1000 experiments, probability of each one winning (new door should be close to 50%, never new door 33%, 50% new door about 41%).
1 from random import * 3 def mean(X): 4 "Mean. Params: X (list, either int or float) Returns: (float) mean of X 6 return sum(X) / len(X) 12 def variance(X): 15 16 """Variance. Params: X (list, either int or float) Returns: (float) variance of X 19 20 21 mu=mean(X) tot = 0.0 for x in X: tot (x mu) **2 += - 23 return tot / len(X) 25 def stdDev(X): 26 27 28 Params: X (list, either int or float) 29 Returns: (float) standard deviation of X 30 31 32 "Standard deviation. return variance (X)**0.5 34 def montyDoor (prize, contestant): 1 from random import * 3 def mean(X): 4 "Mean. Params: X (list, either int or float) Returns: (float) mean of X 6 return sum(X) / len(X) 12 def variance(X): 15 16 """Variance. Params: X (list, either int or float) Returns: (float) variance of X 19 20 21 mu=mean(X) tot = 0.0 for x in X: tot (x mu) **2 += - 23 return tot / len(X) 25 def stdDev(X): 26 27 28 Params: X (list, either int or float) 29 Returns: (float) standard deviation of X 30 31 32 "Standard deviation. return variance (X)**0.5 34 def montyDoor (prize, contestant)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
