       # Re: A Monte Carlo Simulation with loop structure

• To: mathgroup@smc.vnet.net
• Subject: [mg12007] Re: A Monte Carlo Simulation with loop structure
• From: Seth Chandler <SChandler@Central.UH.Edu>
• Date: Fri, 17 Apr 1998 03:40:43 -0400
• Organization: University of Houston
• References: <6gr6oo\$8n4@smc.vnet.net>

```Daniel: I suppose you could use Mathematica conditionals and loop
structures to perform your experiment, but, as you suggest, that would
not be the best way to go. Better to use functional constructs such as
Partition and Apply.Here is an example that takes only a second or two
to run ten thousand simulated dice rolls.

In:=
Needs["Statistics`DataManipulation`"] In:=
results=Frequencies[
Apply[Plus,Partition[Table[Random[Integer,{1,6}],{10000}],3,1],1]];
In:=
ListPlot[Map[Reverse,results],PlotJoined->True];

Seth J. Chandler
Associate Professor of Law
Auto-Didact
and occasional Monte Carlo simulator University of Houston Law Center

Daniel Sanders wrote:

> 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: Re: finite element problem
• Next by Date: Re: calculation
• Prev by thread: A Monte Carlo Simulation with loop structure
• Next by thread: Re: A Monte Carlo Simulation with loop structure