Question: simulate three coin tosses and tabulate the results. Create this program in Python and run it for 10,000 trials, printing out the fraction of trials
simulate three coin tosses and tabulate the results. Create this program in Python and run it for 10,000 trials, printing out the fraction of trials in which there are 0, 1, 2, and 3 heads. Are these fractions what they should be? it should be similar to the matlab program bellow:
N = 10000; % Number of simulations
U = rand(3,N); % a 3-by-N matrix of random numbers from [0,1]
Y = (U < 0.5); % Y=1 (heads) if U < 0.5, otherwise Y=0 (tails)
X = sum(Y); % Sums across columns. X = number of heads
hist(X); % Histogram of X
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
