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

Home » Public Forums » archive » 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 [message #81826 is a reply to message #13427] Thu, 25 October 2012 00:14 Go to previous messageGo to previous message
Yngvar Larsen is currently offline  Yngvar Larsen
Messages: 134
Registered: January 2010
Senior Member
On Wednesday, 24 October 2012 23:38:34 UTC+2, John O'Neill wrote:
> Hello Everyone,
>
> I am trying to create a set of random numbers using an Inverse Gaussian Distribution (Wald distribution) but randomu doesn't seem able to do this. Is there anything more general then randomu, or something where I can define what function I want to use to create random numbers?


Google and Wikipedia are your friends.

http://en.wikipedia.org/wiki/Inverse_Gaussian_distribution#G enerating_random_variates_from_an_inverse-Gaussian_distribut ion

IDL> N = 100
IDL> mu = 1d0 & lambda = 1d0
IDL> nu = randomn(seed, N)
IDL> z = randomu(seed, N)
IDL> igvariates = dblarr(N)
IDL> y = nu^2
IDL> x = mu + mu^2*y/(2*lambda) - mu/2/lambda*sqrt(4*mu*lambda*y + mu^2*y^2)
IDL> ind = where(z le mu/(mu+x), complement=cind)
IDL> igvariates[ind] = x[ind]
IDL> igvariates[cind] = mu^2/x[cind]

Include checking for empty index arrays IND and/or CIND if you use IDL version < 8.0.

--
Yngvar
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: VALUE_LOCATE and NaNs
Next Topic: Re: VALUE_LOCATE and NaNs

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

Current Time: Wed Oct 08 19:28:24 PDT 2025

Total time taken to generate the page: 0.00395 seconds