|
From: | Paul Kienzle |
Subject: | Re: Low hanging fruit - Accelerated random distribution functions |
Date: | Thu, 22 Feb 2007 22:05:39 -0500 |
On Feb 22, 2007, at 7:29 PM, Paul Kienzle wrote:
On Feb 22, 2007, at 11:46 AM, David Bateman wrote:I haven't tried to convert the functions geornd,Octave uses the following; it would be hard to beat: rnd(k) = floor (log (rand (size (k))) ./ log (1 - p(k)));
On second thought, rnd = floor(-rande(n)) ./ log(1-p) is 2x faster.
wblrndFast enough: rnd = scale * -log(1-rand(k))) .^ (1/shape)
1-U and U are equivalent generators, so this should be equivalent to: rnd = scale * rande(size) ^ (1/shape) which will be a bit faster. Note that simplifying the expression on the wikipedia page for the exponential distribution relating it to weibull distribution gives the same result.
[Prev in Thread] | Current Thread | [Next in Thread] |