On Thursday, October 25, 2012 10:37:58 AM UTC-4, David wrote:
> Yngvar Larsen writes:
> > 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#Generating...
> > 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.
> This code is easy enough to implement that I just wrote
> a function, cgRandomWald to do it this morning. You can
> find it here:
> http://www.idlcoyote.com/programs/cgrandomwald.pro
> It works very much like the other RandomX functions in IDL.
> Cheers,
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Sepore ma de ni thue. ("Perhaps thos speakest truth.")
Thank you very much David, Yngvar, and Craig for your help. This is exactly what I was looking for.