Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: A Monte Carlo Simulation with loop structure




Hi Daniel,

//This is the quick and dirty way I did it....define a function to
simulate rolling the three dice m times://

TripleDiceSim[m_] :
able[
{Random[Integer,{1,6}], Random[Integer,{1,6}], Random[Integer,{1,6}]},
{n,1,m}];

	//Then define a function that counts the number of times the dice sum
to nine or ten://

	Count9[ expr_] :ount[ Apply[ Plus, expr, 2 ], 9 ]
	Count10[expr_]:ount[ Apply[ Plus, expr, 2], 10 ]

//Then create a simulation of an ensemble of experiments...each
experiment rolling the three dice 1000 times...and repeating for 200
experiments://

sim 
able[ TripleDiceSim[ 1000 ], {n,1,200} ];

//Then count the number of times the results sum to 9 or 10 for each
experiment, take the ratio, and compute the relevant statistics (make
sure you load "Statistics`" first)://

sim9 ap[ Count9, sim ];
sim10 ap[ Count10, sim ];
ratio im10/sim9 // N;
Mean[ ratio ]
StandardErrorOfSampleMean[ ratio ]

//Doing this gave me the result Mean[ ratio ] .082 with a standard
error 009 which is close to the theoretical value of 1.08//

Hope that helps.

RF


-----Original Message-----
From:	Daniel Sanders [SMTP:dman777@worldnet.att.net] To:
mathgroup@smc.vnet.net
Sent:	Friday, April 17, 1998 1:21 AM To:	mathgroup@smc.vnet.net
Subject:	[mg11971] A Monte Carlo Simulation with loop structure

Hi,
I'm learning Mathematica programming in AutoDidactic [mode], and I'm
working on conditionals and loop structures.  The problem that follows
is prototypical, and perhaps I can benefit from seeing some of your
solutions.
I owe the problem to J. Laurie Snell from his book, "Introduction to
Probability".
In the early 1600s, Galileo was asked to explain the fact that, although
the number of triples of integers from 1 to 6 with sum 9 is the same as
the number of such triples with sum 10, when three dice are rolled, a 9
seemed to come up less often a 10 supposedly in the experience of
gamblers.
Can you suggest native Mathematica code not emulating a procedural
language for a Monte Carlo simulation experiment that runs many times
keeping track of the proportions of 9s and 10s?  Thanks in advance, I'm
interested in the looping mechanism. Daniel Sanders





  • Prev by Date: Q. about Solve as applied to vector equations
  • Next by Date: Re: ReadList of Mixed Data Types???
  • Prev by thread: Re: A Monte Carlo Simulation with loop structure
  • Next by thread: Free 1998 Worldwide Mathematica Conference Poster