/usr/share/doc/ruby-gsl/examples/histogram/gsl-histogram.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 28 29 30 31 32 33 34 35 36 37 38 39 40 | #!/usr/bin/env ruby
# This is equivalent to the gsl-histogram program
require("gsl")
require("getopts")
getopts(nil, "DISPLAY_STATS")
case ARGV.size
when 2
a = ARGV[0].to_f
b = ARGV[1].to_f
n = (b - a).to_i
when 3
a = ARGV[0].to_f
b = ARGV[1].to_f
n = ARGV[2].to_i
else
puts("Usage: : gsl-histogram.rb [--DISPLAY_STATS] xmin xmax [n]")
puts("Computes a histogram of the data on stdin using n bins from xmin to xmax.")
puts("If n is unspecified then bins of integer width are used.")
exit
end
h = GSL::Histogram.alloc(n)
h.set_ranges_uniform(a, b)
while line = STDIN.gets
x = line.chomp.split[0].to_f
h.increment(x)
end
if $OPT_DISPLAY_STATS
printf("# mean = %g\n", h.mean)
printf("# sigma = %g\n", h.sigma)
end
h.fprintf(STDOUT, "%g", "%g")
exit
|