/usr/share/doc/ruby-gsl/examples/histogram/histogram-pdf.rb is in ruby-gsl 2.1.0.3+dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #!/usr/bin/env ruby
require("gsl")
NDATA = 1000
NBINS = 100
MAX = 8
rng = GSL::Rng.alloc()
data = GSL::Ran.gaussian(rng, 1.0, NDATA) + 2
h = GSL::Histogram.alloc(NBINS, [-MAX, MAX])
h.fill(data)
hpdf = GSL::Histogram::Pdf.alloc(h)
rng2 = GSL::Rng.alloc()
h2 = GSL::Histogram.alloc(NBINS, [-MAX, MAX])
NDATA2 = 10000
for i in 0...NDATA2 do
val = hpdf.sample(rng2.uniform())
h2.fill(val)
end
GSL::graph(h, h2)
sum = h.sum() # NDATA
sum2 = h2.sum() # NDATA2
GSL::graph(h, h2.scale(sum/sum2))
|