Coin flip combinations probabilities

I need to write a program what goes as follows:
A fair coin is repeatedly flipped until the last three tosses either show the combination TTH of the combination THH. Here H means that the outcome of a toss is a head and T that it is a tail. What is the probability that the combination TTH occurs before de combination THH?
I hope someone could help me out here...
Thanks alot!

2 件のコメント

Adam Danz
Adam Danz 2020 年 9 月 8 日
What's your question?
Mandip kumar
Mandip kumar 2022 年 11 月 15 日
P(h) = (1/2)c. c! / (h!.(c-h)!)

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2020 年 9 月 8 日

0 投票

You can generate combinations using:
R = [0 1] ; % 0 is T, 1 is H
iwant = zeros([],3) ;
count = 0 ;
i = 0 ;
while count == 0
i = i+1 ;
iwant(i,:) = [R(randperm(2,1)) R(randperm(2,1)) R(randperm(2,1))] ;
if isequal(iwant(i,:),[0 0 1]) || isequal(iwant(i,:),[0 1 1])
count = 1 ;
end
end
iwant

1 件のコメント

Walter Roberson
Walter Roberson 2022 年 11 月 15 日
I would use randi(2, 1, 3)

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeError Functions についてさらに検索

製品

質問済み:

2020 年 9 月 8 日

コメント済み:

2022 年 11 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by