Trying to make a simulated coin flip

16 ビュー (過去 30 日間)
Kathryn Janiuk
Kathryn Janiuk 2020 年 11 月 7 日
回答済み: Asad (Mehrzad) Khoddam 2020 年 11 月 7 日
Hi! I am trying to program a simulated coin flip where I have an equal chance of getting heads vs tails. I am trying to make a loop that subtracts out the 0 when I do the coin flip.
samplesize = 50;
nsamples = 100;
randi([-1,1])
coin_flip = ([-1,1]);
for i = randi([-1,1])
if coin_flip == 0
randi([-1,1])
else
end
end
There's 50 samples with 100 coin flips and I am real sorry if this is a hot mess.
if anyone has any advice I have a solid zero clue what I am doing!!
THANK YOU SOOOO MUCH!!

採用された回答

Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam 2020 年 11 月 7 日
binornd(1,.5,nsamples,1)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by