How to write a program to get probability that two cards same number and same color?
Afficher commentaires plus anciens
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
Réponses (1)
Iain
le 30 Mai 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;
Catégories
En savoir plus sur View and Analyze Simulation Results dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!