Sha256: aa652f822a1542090b9a23de2a99476feb11c039de253ac871c45acfd8f45d69

Contents?: true

Size: 782 Bytes

Versions: 22

Compression:

Stored size: 782 Bytes

Contents

#!/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

Version data entries

22 entries across 22 versions & 4 rubygems

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