Re: Monte Carlo speed - Compound Poisson
- From: tristram.scott@xxxxxxxxxxxx (Tristram Scott)
- Date: Fri, 11 Dec 2009 10:34:43 GMT
Ben Petschel <noreply@xxxxxxxxxx> wrote:
One of my colleagues claimed that "FORTRAN would be way faster thanMATLAB for doing Monte Carlo simulation".
Here we're interested in generating Compound Poisson random variables -
that is, random variables of the form X1+...+XN where N is random with the
Poisson distribution. I tested various codes for generating 1 million
Poisson(10)-Lognormal(0,1) samples and with careful vectorization brought
the MATLAB run time down from 200+ sec to about 1.2 sec, not far off the
theoretical limit of about 0.8 sec imposed by randn (see FEX #26042
<http://www.mathworks.com/matlabcentral/fileexchange/26042> for details).
So your process here was to generate 1 million Poisson samples, with mean
of 10, and then generate around 10 million Lognormal samples, and sum them?
What are you using to generate the Poisson samples? How much of your cpu
time is spent doing Poisson, how much doing Lognormal, how much doing the
sums?
"Fast Generation of Discrete Random Variables", Marsaglia, Tsang and Wang,
Jornal of Statistical Software, vol 11, Issue 3, July 2004.
The above paper has an excellent method which is very fast. Generation of
Poisson variates should approach the speed with which you can generate
uniform variates.
By comparison, SAS and Mathematica implementations took about 3 sec and
10 sec respectively, though I'm not enough of an expert to say if that is
the fastest possible time in those languages.
The question is, how much further speed gain could be realized by going
to the trouble of implementing an algorithm in a "faster" language such as
C or FORTRAN?
If you wnat to go multi-threaded, potentially quite a bit. Even if not, if
the answer to my question above is that lots of time is required for
Poisson c.f. the genrating same number of Uniform variates, then also quite
a bit.
I have C implementations available, but don't do Fortran myself. I doubt
that you ould see much difference at all between C and Fortran for this,
but there is certainly scope for improvement over what is available in
MATLAB, SAS or MAthematica.
--
Dr Tristram J. Scott
Energy Consultant
.
- Follow-Ups:
- Re: Monte Carlo speed - Compound Poisson
- From: Ben Petschel
- Re: Monte Carlo speed - Compound Poisson
- References:
- Monte Carlo speed - Compound Poisson
- From: Ben Petschel
- Monte Carlo speed - Compound Poisson
- Prev by Date: netlist to MNA equations
- Next by Date: mdlInitializeCondition execution time
- Previous by thread: Monte Carlo speed - Compound Poisson
- Next by thread: Re: Monte Carlo speed - Compound Poisson
- Index(es):
Relevant Pages
|