Random Drawing Simulation -- performance issue

Paul Rubin http
Tue Sep 12 23:17:47 EDT 2006


"Travis E. Oliphant" <oliphant.travis at ieee.org> writes:
> > I need to simulate scenarios like the following: "You have a deck of
> > 3 orange cards, 5 yellow cards, and 2 blue cards. You draw a card,
> > replace it, and repeat N times."
> >
> Thinking about the problem as drawing sample froms a discrete
> distribution defined by the population might help.

Is there some important reason you want to do this as a simulation?
And is the real problem more complicated?  If you draw from the
distribution 100,000 times with replacement and sum the results, per
the Central Limit Theorem you'll get something very close to a normal
distribution whose parameters you can determine analytically.  There
is probably also some statistics formula to find the precise error.
So you can replace the 100,000 draws with a single draw.



More information about the Python-list mailing list