Simulate the tossing of a fair coin. Repeat the experiment 1000 and verify that the number of times in which a head appeared is almost 500.

3 visualizzazioni (ultimi 30 giorni)
i cannot do the loop in this simulation please help

Risposte (1)

Image Analyst
Image Analyst il 22 Dic 2014
That's fine, because a loop is not needed. Hint:
tosses = randi(2, 1,1000) - 1;
and I'm sure you've heard of the sum() function so make sure you don't name any variable in your program "sum".

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by