Thank you. I had not seen in statdist a general Gamma, so I just assumed that gammarand was not general when in fact it is just fine. The shape parameter is the power parameter whereas the scale parameter is not nesseray as scaling is achieved by simply multiplying the resulting array.
On Tue, Aug 5, 2008 at 3:46 PM, Sherlock, Ric <[EMAIL PROTECTED]>wrote: > ---Robert Cyr wrote: > > More general than the ! gamma J function, we can use: > > gma=: 4 : 0 > > 'a b'=.x > > (((y%b)^<:a)*^-y%b)%b*!<:a > > ) > > where a is the shape parameter and b is the scale parameter. > > > > I am looking for a Gamma distribution randon number generator in J. > > >From the statdist.ijs script ( open 'statdist' ) > > NB. ========================================================= > NB. gammarand > NB. random numbers in a gamma distribution > NB. y has 2 elements p,n > NB. 0 = power parameter > NB. 1 = number of trials > NB. > NB. if p=1 this is the exponential distribution > gammarand=: 3 : 0 > 'p n'=. y > r=. n#0 > k=. p-i=. <.p > if. k do. > r=. betarand k,(-.k),n > r=. r * -^.rand01 n > end. > if. i do. > r-^.*/rand01 i,n > end. > ) > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
