comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: random numbers with gamma distribution
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: random numbers with gamma distribution [message #13417 is a reply to message #13416] Wed, 04 November 1998 00:00 Go to previous messageGo to previous message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
In article <MPG.10aa14fba7d2a20d989703@news.frii.com> davidf@dfanning.com \
(David Fanning) writes:

> T.Osborn (f055@uea.ac.uk) writes:
>
>> I'm trying to generate a random series that has a gamma distribution, using
>> the randomu() function with the gamma keyword. The online help says to set
>> gamma to an integer > 0. WHY DOES IT HAVE TO BE AN INTEGER? The gamma
>> distribution is in fact defined for all gamma > 0, not just integers.
>> I want to set gamma=0.5, which currently fails as it converts it to the
>> integer 0, which is not > 0, and so it fails.
>>
>> Is this a bug, and is there any work-around?
>
> Which gamma function are you running? Certainly not IDL's
> GAMMA function which works perfectly well with non-integer
> values:
>
> IDL> print, gamma(0.5)
> % Compiled module: GAMMA.
> 1.77245

:-)

Read his post one more time, David - and open your eyes this time :-)

A number of useful options have been added to the RANDOMU function
since I (we?) "learned" it. I don't know which version added the stuff,
but you can now generate random numbers with various distributions
(poisson, binomial, gamma, normal, uniform) straight away by setting
some keywords. The /NORMAL keyword gives you the same as RANDOMN.

As far as I can make out a gamma distribution is proportional to

x^(g-1)*exp(-x)
--------------
(g-1)

From the formula you wouldn't expect any problems with g being
fractional...since x is always positive. But I guess the
implementation is easier if g is restricted to integers...

Regards,

Stein Vidar
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Programs that Work on 24-bit Color Displays (Long)
Next Topic: Re: Strange UNIX or strange IDL?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 22:20:10 PDT 2025

Total time taken to generate the page: 0.95879 seconds