From: Josiah McGuckin on 26 Jan 2010 10:55 I have written two m-files: one to take a 52-card deck of cards and "shuffle" it, and another to "deal" 4 hands of cards from that deck (in other words, I have a 4x13 matrix of values between 1 and 13)... at this point, I am expected to determine the probability of being dealt a single ace, two aces, or an ace and a deuce. I have been trying to make heads or tails of this problem for the last week and have absolutely no idea where to start on this, so any help in getting my "prob" m-file started would be appreciated. by the way, if posting my "deal" m-file would help, please let me know.
From: John D'Errico on 26 Jan 2010 11:23 "Josiah McGuckin" <josiah.mcguckin(a)gmail.com> wrote in message <hjn397$jd0$1(a)fred.mathworks.com>... > I have written two m-files: one to take a 52-card deck of cards and "shuffle" it, and another to "deal" 4 hands of cards from that deck (in other words, I have a 4x13 matrix of values between 1 and 13)... at this point, I am expected to determine the probability of being dealt a single ace, two aces, or an ace and a deuce. I have been trying to make heads or tails of this problem for the last week and have absolutely no idea where to start on this, so any help in getting my "prob" m-file started would be appreciated. > > by the way, if posting my "deal" m-file would help, please let me know. It appears that you are trying to represent the cards in each hand by numbers that all lie between 1 and 13. Since there are 52 cards in the deck, this would seem to be wrong. It is better to represent the cards in each hand by some subset of the numbers 1:52. What would randperm(52) do for you? Could you reshape that result to give you the requisite 4x13 array? Having done that, just decide which numbers correspond to each card value, and then count the number of events in a simulation that have the desired property. John
From: ImageAnalyst on 26 Jan 2010 11:29 Josiah McGuckin: Well I can't do it ALL for you but this should get you started: % sortedDeck = 1:52 shuffledDeck = randperm(52) acePositions = 1:13:52 deucePositions = 2:13:52 topFourCards = shuffledDeck(1:4) aceInTopFourCards = ismember(topFourCards, acePositions) deuceInTopFourCards = ismember(topFourCards, deucePositions) Now just put his in a loop that checks for aces and deuces like a million times and calculate the probability. I think you get the idea....
|
Pages: 1 Prev: script running stop in the middle Next: bug with MATLAB example avifile |