Re: probability with simulation

*To*: mathgroup at smc.vnet.net*Subject*: [mg60520] Re: [mg60496] probability with simulation*From*: "W. Craig Carter" <ccarter at mit.edu>*Date*: Mon, 19 Sep 2005 04:45:39 -0400 (EDT)*References*: <200509180515.BAA02275@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Without doing the entire set of problems, here is something that is straightforward, not terribly efficient, but can probably be modified to help you move forward: << DiscreteMath`Combinatorica` (*we want the RandomPermutation[]*) (*The following function is a single deal, you get the first five cards and they are sorted (i.e., Sort[Take[deal,5]]). The we check if the cards make as sequence, returning a zero as soon as we determine that your hand is not a sequence. If you look through all the cards and it is a sequence, return a 1*) ATrial[numcards_] := Module[ {deal = RandomPermutation[numcards], hand, check = 1}, hand = Sort[Take[deal, 5]]; While[check < 5 , If[deal[[check]] != deal[[++check]] - 1, Return[0]]]; Return[1] ] (*So we count the number of successes to get a probability estimate:*) ProbEst[NCards_, NTrials_] := Sum[ATrial[NCards], {NTrials}]/NTrials (*and then run a simulation over a large number of trials*) ProbEst[10, 10000] (*which returned a 1/5000 for me*) Note, for rare events, convergence to the actuall probablility will be slow and therefore you will want to get a sense of the convergence... On Sun, 18 Sep 2005, Sara wrote: > Date: Sun, 18 Sep 2005 01:15:51 -0400 (EDT) > From: Sara <ma_sara177 at hotmail.com> To: mathgroup at smc.vnet.net > Subject: [mg60520] [mg60496] probability with simulation > > I have a problem with probability. I have to solve a problem av probability with simulation. i have done it with the combinatorial method but I dont know how to use Mathematica to solve the problem with simulation. can any one Help me please. If you want my result with combinatorial method or my try with simulation I can email you. the problems are: > > 1)Find the probability of getting exactly two 1:s when throwing 5 dices. > Solve this problem with the combinatorial method and by simulation. > > We will play a very simple variant of poker. In the deck we have N cards which are > called 1,2, ?, N. Each player is dealt 5 cards randomly. In this game there are 3 types > of hands: > ? Straight: The 5 cards form a sequence, e.g. 3,4,5,6,7. > ? Parity: The 5 cars are all odd or all even. > ? Standard: A hand that is not a Straight or a Parity. > A Straight beats a Parity and a Parity beats a Standard. If we have two hands of the > same type the hand with the highest top-card will win. > Problem 1 > Assume that there are 3 players including you. What is the probability that you get a > Straight? Solve this problem first with. > The combinatorial method? (ihave don that) > Simulation? > Do it for N=15. Make a simulation for N=20. > Problem 2 > Let us assume N= 30, that there are 4 players including you, that the cards are dealt > and you have a Parity with 20 as top-card. What is the probability that you have a > winning hand? > > W. Craig Carter Lord Foundation Professor of Materials Science and Engineering MIT, Dept. of Materials Science and Engineering 13-5018 77 Massachusetts Ave, Cambridge, MA 02139-4307 USA 617-253-6048 ccarter at mit.edu http://pruffle.mit.edu/~ccarter http://pruffle.mit.edu/~ccarter/FAQS/ http://pruffle.mit.edu/~ccarter/I_do_not_use_microsoft.html

**References**:**probability with simulation***From:*Sara <ma_sara177@hotmail.com>

**Re: calling a C executable from within Mathematica**

**A Su Doku solver**

**Re: probability with simulation**

**Re: probability with simulation**