Sha256: 296e0f62e59bbdb58968fb81f43e14495fab054c60b565ea2b39ba308d357680

Contents?: true

Size: 490 Bytes

Versions: 22

Compression:

Stored size: 490 Bytes

Contents

#!/usr/bin/env ruby
require("gsl")

N = 10000
BINS = 100

rng1 = GSL::Rng.alloc(2)

h = GSL::Histogram.alloc(BINS, [-5, 5])

for i in 0...N do
  r1 = rng1.gaussian
  h.increment(r1)
end

# Integrate: cumulative distribution
hi = h.integrate

a = hi.diff

# Scale the histograms to ~ 1 at the maximum (to display together)
h.scale!(1.0/h[BINS/2])
a.scale!(1.0/a[BINS/2])

hi.normalize!                  # this is equivalent to hi.scale(1.0/hi[BINS-1])

GSL::graph(h, hi,a,  "-T X -C -g 3")

Version data entries

22 entries across 22 versions & 4 rubygems

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