[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Low hanging fruit - Accelerated random distribution functions
From: |
David Bateman |
Subject: |
Re: Low hanging fruit - Accelerated random distribution functions |
Date: |
Fri, 23 Feb 2007 11:27:14 +0100 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
Paul Kienzle wrote:
>
> 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.
Are you sure its not the reverse
octave:3> function rnd = geornd2(p,varargin), rnd =
floor(-rande(varargin{:})) ./ log(1-p); endfunction
octave:4> tic; b0 = geornd(3,1,1e7); toc
Elapsed time is 1.643173 seconds.
octave:5> tic; b1 = geornd2(3,1,1e7); toc
Elapsed time is 3.176453 seconds.
D.
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
Re: Low hanging fruit - Accelerated random distribution functions, Paul Kienzle, 2007/02/22
Re: Low hanging fruit - Accelerated random distribution functions, David Bateman, 2007/02/23