Question: please I need help Exit Fullscreen 0.1. Simulating Coin Toss Experiments As mentioned in class, there are many ways to model stochastic experiments. The following

please I need help

please I need help Exit Fullscreen 0.1. Simulating Coin Toss Experiments As

Exit Fullscreen 0.1. Simulating Coin Toss Experiments As mentioned in class, there are many ways to model stochastic experiments. The following two programs simulate the toss of a fair coin for N= 100,000 times, and calculate the experimental probability of getting heads (p_heads) or tails (p_heads). Both programs provide the same results, but they differ in the way the models are coded. The first model is programmed using "for loops". The second model makes use of the MATLAB vector objects, and it is computationally very efficient. . MODEL 2 -- EFFICIENT CODE clear N=100000; heads=sum (round(rand (N,1))); tails=N-heads; p heads=heads/N p_tails=tails/N MODEL 1 -- INEFFICIENT CODE clear N=100000; heads=0; tails=0; for f=1:N coin-round (rand); if (coin==1) heads=heads+1; else tails=tails+1; end end p_heads=heads/N p tails=tails/N Exit Fullscreen 0.1. Simulating Coin Toss Experiments As mentioned in class, there are many ways to model stochastic experiments. The following two programs simulate the toss of a fair coin for N= 100,000 times, and calculate the experimental probability of getting heads (p_heads) or tails (p_heads). Both programs provide the same results, but they differ in the way the models are coded. The first model is programmed using "for loops". The second model makes use of the MATLAB vector objects, and it is computationally very efficient. . MODEL 2 -- EFFICIENT CODE clear N=100000; heads=sum (round(rand (N,1))); tails=N-heads; p heads=heads/N p_tails=tails/N MODEL 1 -- INEFFICIENT CODE clear N=100000; heads=0; tails=0; for f=1:N coin-round (rand); if (coin==1) heads=heads+1; else tails=tails+1; end end p_heads=heads/N p tails=tails/N

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!