Re: probability with simulation

• To: mathgroup at smc.vnet.net
• Subject: [mg60515] Re: [mg60496] probability with simulation
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Mon, 19 Sep 2005 04:45:35 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Here is an example of a simulation to get you started

nbrDice=5;
nbrOnes=2;
nbrFaces=6;

Enumeration:

Count[Count[#,1]&/@
Flatten[
Outer[List, Sequence@@Table[Range[nbrFaces], {nbrDice}]],
nbrDice-1],
nbrOnes]/(nbrFaces^nbrDice)//N

0.160751

Combinatoric:

(1/nbrFaces)^nbrOnes*(1-1/nbrFaces)^(nbrDice-nbrOnes)*
Binomial[nbrDice, nbrOnes]//N

0.160751

%==%%

True

Estimate using simulation:

Module[{nbrTrials=1000,n=0},
Do[If[
Count[
Table[Random[Integer,{1,nbrFaces}],{nbrDice}],
1]==nbrOnes,
n+=1],
{nbrTrials}];
N[n/nbrTrials]]

0.165

Bob Hanlon

>
> From: Sara <ma_sara177 at hotmail.com>
To: mathgroup at smc.vnet.net
> Date: 2005/09/18 Sun AM 01:15:51 EDT
> Subject: [mg60515] [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?
>
>

```

• Prev by Date: Decimal comma on input
• Next by Date: Re: calling a C executable from within Mathematica
• Previous by thread: Re: probability with simulation
• Next by thread: Re: Extracting coefficients for sinusoidals