How can I use matlab to solve this probability problem ?

7 views (last 30 days)
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 ?

Accepted Answer

Image Analyst
Image Analyst on 1 Nov 2014
This is a standard Monte Carlo simulation. Is this homework, or just a puzzle that you're wanting to do? First of all you need to describe an experiment as Tom pulling 2 cards, replacing them, and Laura taking two cards and replacing them. Then you run that experiment a lot, say a million times, keeping track of the results each time. Note that this is the same as donig Tom a million times and then doing Laura a million times since when Larua draws, it's from the full set of cards. Then get the percentages over the million experiments. Here's a hint. You can use randperm() to get a draw of two cards like this
drawnCards = randperm(10, 2); % Get two random numbers between 1 and 10.
Now you need to check what his prize is. There are more efficient ways to do it, but this way is easy to understand. I show for Tom. Run again for Laura.
clc;
tic;
prizeAmounts = [1000, 500, 200, 300, 0, 0, 0, 0, 0, 0];
% First do for Tom
numPrizesWon = 0;
moneyWon = 0;
totalNumberOfExperiments = 10000;
for experiment = 1 : totalNumberOfExperiments
drawnCards = randperm(10, 2);
% Count the money won during this experiment.
moneyWonThisTime = sum(prizeAmounts(drawnCards));
% Add it to our grand total amount won over all experiments so far.
moneyWon = moneyWon + moneyWonThisTime;
% Count the number of prizes won
wonPrize = ismember(drawnCards, 1:4); % 0 or 1 depending if he won
numPrizesWon = numPrizesWon + sum(wonPrize);
end
fprintf('Tom drew %d cards in %d experiments.\n%d cards won, and he won a grand total of %d cents\n',...
2*totalNumberOfExperiments, totalNumberOfExperiments, numPrizesWon, moneyWon);
toc;
tic;
% Now do for Laura.
I didn't really understand the grammar of the last sentence so I don't know what that means but I'm sure it would be easy to check for, if you did know what it meant.

More Answers (2)

piggy_jes
piggy_jes on 13 Nov 2014
Hi,
Sorry for my unclear statement. The last sentence mean the problem ask to know what's the probability that the "difference amount of money" that "received by Tom and Laura" are not exceed 500 cent ?
Thank you

Michael
Michael on 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.

Categories

Find more on Graphics Performance 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!