Question
Do the following in MATLAB: trials = 100; flip = rand(trials,1); heads = (flip >= 0.5); percentheads = sum(heads)/trials a.We can use a random number
Do the following in MATLAB:
trials = 100;
flip = rand(trials,1);
heads = (flip >= 0.5);
percentheads = sum(heads)/trials
a.We can use a random number generator to estimate probabilities that might otherwise be difficult to evaluate. Consider the probability of obtaining four heads on four flips. Generate four separate random experiments of 0s and 1s representing N trials each. (You can do this by generating an Nx4 random array rather than an Nx1 array as in #1.) Now look at the corresponding rows and determine what percentage of the time all four coin flips across a row are heads (all entries equal 1). Show how you do this in MATLAB. Report the percentage with N=10,000 and 100,000, and compare this to the expected percentage.
b.Suppose the coin is unfair and has a 45% probability of being heads. You want to test this coin by doing 100 coin flips. Modify your code from #1 so that the probability of heads is 0.45. If you repeat this 100-flip experiment over and over, the relative frequency should vary around 0.45. How likely is it that the result will show a fair coin by giving a relative frequency of 50% or higher? Calculate the expected percentage of times this would happen by doing this 100-flip experiment 1000 times and calculating the percentage of time the relative frequency in 100 flips is 50% or higher. Does 100 flips appear to be enough trials to reliably detect an unfair coin with a 45% probability of heads?
please answer these a and b, thanks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started