How to write a program to get probability that two cards same number and same color?
1 次查看(过去 30 天)
显示 更早的评论
I need to write a program to get probability that both two cards are the same number(two cards are selected at random from an ordinary pack of 52 cards ) (1-1, 2-2, ..., 10-10) and the same color (Red-Red, Black-Black).with using a billon random events
0 个评论
回答(1 个)
Iain
2013-5-30
If you're asking the question:
You take the Ace of spades from a standard 52 card deck, and you want to know the likelihood that you will then draw a black ace (the ace of clubs) from the remaining 51 cards, then the answer is 1 in 51.
Regardless of card, its 1 in 51.
matches = 0;
for i = 1:1e9
if ceil(rand()*51) == 1
matches = matches + 1;
end
end
measured_probability = matches / 1e9;
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!