A perfect coin should produce heads and tails with equal probability. If we assign the number 0 toheads and the number 1 to tails, then we can mimic such a perfect coin in Matlab. Specifically, we cangenerate N “coin flips” in Matlab by doing x= (rand(N, 1) < 0.5 );, where becomes an array of zeros(“heads") and ones (“tails"). For a perfect coin, the mean of that array should be exactly 0.5. Experimentwith how many coin flips you need to get close to this value. Specifically, generate N = 16 coin flips and compute the sample mean (in Matlab, mean(x)). Then generate N = 32 coin flips and compute a newmean. Repeat this process for N = 2k for k = 4,5,…,26. For each value of N, the error in your computedmean is the absolute value of the computed sample mean and 0.5 (i.e., error = abs( mean(x) - 0.5 );). Plot this error vs N. Try linear and logarithmic axes. What patterns do you see?
This question is on Chegg, if anyone has an account, could you please screenshot it? If possible.