How to write a program to get probability that two cards same number and same color?
Show older comments
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
Answers (1)
Iain
on 30 May 2013
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;
Categories
Find more on View and Analyze Simulation Results in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!