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

Version Path
gsl-2.1.0.3 examples/histogram/poisson.rb
gsl-2.1.0.2 examples/histogram/poisson.rb
gsl-2.1.0.1 examples/histogram/poisson.rb
gsl-2.1.0 examples/histogram/poisson.rb
gsl-1.16.0.6 examples/histogram/poisson.rb
rb-gsl-1.16.0.5 examples/histogram/poisson.rb
rb-gsl-1.16.0.4 examples/histogram/poisson.rb
rb-gsl-1.16.0.3 examples/histogram/poisson.rb
rb-gsl-1.16.0.3.rc1 examples/histogram/poisson.rb
gsl-nmatrix-1.15.3.2 examples/histogram/poisson.rb
gsl-nmatrix-1.15.3.1 examples/histogram/poisson.rb
rb-gsl-1.16.0.2 examples/histogram/poisson.rb
rb-gsl-1.16.0.1 examples/histogram/poisson.rb
rb-gsl-1.16.0 examples/histogram/poisson.rb
rb-gsl-1.15.3.2 examples/histogram/poisson.rb
rb-gsl-1.15.3.1 examples/histogram/poisson.rb
blackwinter-gsl-1.15.3.2 examples/histogram/poisson.rb
gsl-nmatrix-1.15.3.0 examples/histogram/poisson.rb
gsl-1.15.3 examples/histogram/poisson.rb
gsl-1.14.7 examples/histogram/poisson.rb