Libra wrote: > Hello, > > I would extract some numbers according to a given probability > distribution (at least, Normal, Exponential, Poisson and Bernoulli). > > Do you know if a similar library already exists in Ruby? I only found > pseudo-random number generator. > > TIA > > 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 > #!/usr/bin/env ruby > require("gsl") > > N = 10000 > MAX = 8 > rng = Rng.alloc(2) > > data = Ran.gaussian(rng, 1.5, N) + 2 > h = GSL::Histogram.alloc(100, [-MAX, MAX]) > h.increment(data) > > 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