Re: Monte Carlo speed - Compound Poisson



Ben Petschel <noreply@xxxxxxxxxx> wrote:
One of my colleagues claimed that "FORTRAN would be way faster than
MATLAB 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
.



Relevant Pages

  • Simple Treatment of Poisson Distribution?
    ... As a statistics teacher who never had a course in ... I set out to explain Poisson random variables ... most of the derivations of the Poisson ... Let us assume that randomly occurring incidents occur ...
    (sci.math)
  • Re: Simple Treatment of Poisson Distribution?
    ... I set out to explain Poisson random variables ... most of the derivations of the Poisson ... >over time with an average frequency of r incidents per ...
    (sci.math)
  • Re: Suggestion Wanted: CI of Poisson times Gamma RV
    ... My estimator is this Poisson RV, ... defects occur, you don't want the product of the two random variables. ... You're simply using the Poisson-Gamma distribution to model the process. ...
    (sci.stat.math)
  • Re: correlated random numbers (poisson)
    ... random variables with N different parameters Lambda and a given ... For a Poisson vector x with a given mean vector L and correlation ... I don't get it :-( Can somebody formulate it into program-code ...
    (sci.stat.math)