From: "M. Edward (Ed) Borasky" Date: 2007-08-25T13:06:02+09:00 Subject: Re: Probability distributions library in Ruby Roger Pack wrote: >>From wikipedia : algorithm for generating pseudo poissons: > > def poisson(lambda) > > # init > l = Math.exp(-lambda) > k = 0 > p = 1 > while p >= l > k += 1 > u = rand > p = p *u > end > return k -1 > end > > only returns ints, but hey, they center around lambda > gl. > -Roger > > maw wrote: >> Libra wrote: >>> Libra >> R is great! maybe too great for your requirements >> rb-gsl is easy >> >> for example this will print you a nice gauss-shape graph >> from rb-gsl-1.8.3/samples/histogram/gauss.rb >>> sigma, mean, height, = h.fit_gaussian >>> >>> x = GSL::Vector.linspace(-MAX, MAX, 100) >>> y = height*Ran::gaussian_pdf(x-mean, sigma) >>> GSL::graph(h, [x, y], "-T X -C -g 3") >> NICE! >> >> cauchy exponential power poisson etc. also available >> ruby - making maths easy > There is also RSRuby, a way of calling the R libraries, including their probability distribution routines, from Ruby. I don't know anything about the ones in GSL, but I know the algorithms in R are first-rate, and I wouldn't code my own no matter *how* bored I got. :)