Sha256: d9c7a9a2ab8ef3d5348132a781e0cae666720493167cd322d03f2efd875e591e
Contents?: true
Size: 419 Bytes
Versions: 22
Compression:
Stored size: 419 Bytes
Contents
#!/usr/bin/env ruby require("gsl") GSL::Rng.env_setup() N = 10000 rng = GSL::Rng.alloc h = GSL::Histogram.alloc(20, [0, 20]) =begin for i in 0...N do r = rng.poisson(5) # r = GSL::Ran::poisson(rng, 5) h.increment(r) end =end v = rng.poisson(5, N) h.fill(v) h.normalize! x = GSL::Vector.linspace(0, 20, 100) y = GSL::Ran::poisson_pdf(x, 5) GSL::graph(h, [x, y], "-C -g 3 -L 'Poisson distribution, mu = 5'")
Version data entries
22 entries across 22 versions & 4 rubygems