[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: poisson_rnd() excruciatingly slow
From: |
Paul Kienzle |
Subject: |
Re: poisson_rnd() excruciatingly slow |
Date: |
Wed, 6 Oct 2004 23:53:58 -0400 |
I've posted randp() to octave-forge/FIXES. The code for
the 5 (?!) generators is in randpoisson.c. There are
different generators for large (>10) and small lambda (<10),
and for repeated and varying lambda. Some algorithms have
considerable initialization overhead when changing
lambda. Also, for huge lambda (>1e8) a normal approximation
is used.
Be careful to test that the generated numbers look
reasonable for all these cases before putting your
trust in this code. Test showing that the resulting
numbers are indeed Poisson would be appreciated.
Here are some times:
uniform generator
octave> tic; rand(400); toc
ans = 0.042940
repeated lambda, small and large
octave> tic; randp(5,400); toc
ans = 0.055537
octave> tic; randp(155,400); toc
ans = 0.11648
varying lambda, small and large
octave> tic; randp(5*ones(400),400); toc
ans = 0.20203
octave> tic; randp(155*ones(400),400); toc
ans = 0.58247
I've just noticed that randn is very slow on OS X:
octave> tic; randn(400); toc
ans = 12.868
Some concerned mac users may want to pursue this.
It should be just a little slower than rand(), not 300x
slower.
- Paul
On Oct 6, 2004, at 8:24 PM, address@hidden wrote:
Is there a reason why poisson_rnd() is so *glacially slow* for high
values
of lambda? On a 2.0 GHz Athlon system, I measured poisson_rnd(200000)
to
take approximately 18 seconds, making this function next to useless for
practical use. Compare that to the 0.16 seconds for
binomial_rnd(400000,
0.5) which effectively computes the same thing, which I still consider
to
be a sizable amount, by the way.
If my questions have already been answered on various lists, then I
apologize for asking them, but as the search-function of said lists
seems
to be down, I cannot check myself.
Kind regards,
Maarten
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------