How can I use matlab to solve this probability problem ?
Afficher commentaires plus anciens
There are 10 lottery cards in a box that each has its number from 1 to 10. The cards number 1,2,3 and 4 have lottery prize of 1000, 500, 200, 300 cent respectively, the other don't. Tom choose 2 cards randomly and he got the prize, then he put the cards back into the box. Laura choose 2 cards randomly and she got the prize too.
What is the probability that Tom will receive money different from Laura no more than 500 cent ?
Réponse acceptée
Plus de réponses (2)
piggy_jes
le 13 Nov 2014
0 votes
Michael
le 13 Nov 2014
This problem doesn't strike me as complex enough for a Monte Carlo approximation of the answer. The answer can be determined precisely using very little code.
First, the generation of the set of possible draws is quite simple:
draws = nchoosek(1:10,2);
There are 45 possible draws, each with an equal likelihood of occurring. Now for each of these draws we can come up with the total value of that draw:
values = sum(prizeAmounts(draws),2);
Then a simple for loop can determine the percentage of Laura's draws that meet the criteria based on each of Tom's draws.
percentages = zeros(size(values));
n=numel(values);
for i=1:numel(values)
percentages(i) = numel(values(abs(values-values(i)) <= 500))/n;
end
And since all draws are equally likely, the final answer is simply the mean of the percentages for each draw.
result = mean(percentages);
Of course, this code could get unwieldy if the number of cards or draws gets too high, but for the specific question being asked, I think that an exact answer is obtainable without too much effort.
Catégories
En savoir plus sur Loops and Conditional Statements 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!