Question
MATLAB 1. Write a MATLAB function that simulates an experiment in which a coin is flipped 100 times and the number of heads (successes) is
MATLAB
1. Write a MATLAB function that simulates an experiment in which a coin is flipped 100 times and the number of heads (successes) is recorded. The input to this function should be the probability of observing a heads and the output should be a number between 0 and 100.
2. In a separate script, use the function from 1. to simulate an experiment where you flip a fair coin (input to function is 0.5) 100 times, record the number of heads observed, and then repeat the coin flip experiment 10, 100, and 1000 times -- thus, for 10 repetitions, the resulting outcomes might look like [50,51,47,45,53,55,50,51,48,40]. Plot your results from the 10, 100, and 1000 repetitions of the 100 coin flip experiment in 3 separate histograms.
3. Redo the experiment in 2, but this time assume an unfair coin (probability of observing heads is 0.8)
4. Based on the histograms, how does it appear that the number of heads observed in 100 flips of a coin are distributed? Overlay the analytical distribution on the histogram of the simulated data.
5. Prove that the variance of the Poisson distribution with mean lambda is also lambda.
as a hint, the built-in rand function returns a random number from the uniform distribution between 0 and 1. Thus to simulate a single fair coin flip you might use something like:
if rand > 0.5
disp('heads')
else
disp('tails')
end
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