Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Probability question?

Subject: Probability question?

From: jinniwinni

Date: 28 Sep, 2012 04:58:07

Message: 1 of 1

Write a program that tosses a (fair) coin n times and records whether or not the proportion of heads is between 0.4 and 0.6 after each set of n tosses. Repeat this experiment 2000 times. About how large must n be so that the proportion of heads is between 0.4 and 0.6 about 95% of the time?


How would you do this question? Here is the code :

function percentage = coinTosses(run_time, n)
flips = zeros(1,n);
for i=1:n
    
    flips(i) = randi(2) - 1;
number_of_heads = sum(flips);
proportion_of_heads = number_of_heads/n;

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us