GSL::Histogram2d.new(nx, ny)
GSL::Histogram2d.new(xrange, yrange)
GSL::Histogram2d.new(nx, xmin, xmax, ny, ymin, ymax)
GSL::Histogram2d.new(nx, [xmin, xmax], ny, [ymin, ymax])
With sizes
irb(main):002:0> h2 = GSL::Histogram2d.alloc(2, 3) # size 6 irb(main):003:0> h2.xrange => GSL::Histogram::Range: [ 0.000e+00 1.000e+00 2.000e+00 ] irb(main):004:0> h2.yrange => GSL::Histogram::Range: [ 0.000e+00 1.000e+00 2.000e+00 3.000e+00 ] irb(main):005:0> h2.bin => GSL::Histogram::Bin: [ 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 ] irb(main):006:0> h2.xrange.class.superclass => GSL::Vector::View::ReadOnly irb(main):007:0> h2.bin.class.superclass => GSL::Vector::View::ReadOnly
With ranges
irb(main):006:0> h2 = Histogram2d.new([3, 6, 7], [2, 3, 8]) irb(main):007:0> h2.xrange => GSL::Histogram::Range: [ 3.000e+00 6.000e+00 7.000e+00 ] irb(main):008:0> h2.yrange => GSL::Histogram::Range: [ 2.000e+00 3.000e+00 8.000e+00 ] irb(main):009:0> h2.bin => GSL::Histogram::Bin: [ 0.000e+00 0.000e+00 0.000e+00 0.000e+00 ]
With sizes and ranges
irb(main):010:0> h2 = Histogram2d.new(4, [0, 4], 3, [1, 5]) irb(main):011:0> h2.xrange => GSL::Histogram::Range: [ 0.000e+00 1.000e+00 2.000e+00 3.000e+00 4.000e+00 ] irb(main):012:0> h2.yrange => GSL::Histogram::Range: [ 1.000e+00 2.333e+00 3.667e+00 5.000e+00 ]
GSL::Histogram2d.new_uniform(nx, xmin, xmax, ny, ymin, ymax)
GSL::Histogram2d.alloc_uniform(nx, xmin, xmax, ny, ymin, ymax)
GSL::Histogram2d.equal_bins_p(h1, h2)
GSL::Histogram2d#set_ranges(vx, vy)
GSL::Histogram2d#set_ranges_uniform(xmin, xmax, ymin, ymax)
GSL::Histogram2d#set_ranges_uniform([xmin, xmax], [ymin, ymax])
GSL::Histogram2d#clone
GSL::Histogram2d#duplicate
GSL::Histogram2d#increment(x, y, weight = 1)
GSL::Histogram2d#accumulate(x, y, weight = 1)
GSL::Histogram2d#fill(x, y, weight = 1)
GSL::Histogram2d#increment2(x, y, weight = 1)
GSL::Histogram2d#accumulate2(x, y, weight = 1)
GSL::Histogram2d#fill2(x, y, weight = 1)
GSL::Histogram#increment/accumulate/fill
,
but when (x,y) lies outside the limits of the histogram then the edge
bin is incremented.GSL::Histogram2d#get(i[, j])
GSL::Histogram2d#get([i, j])
GSL::Histogram2d#[i, j]
GSL::Histogram2d#get_xrange(i)
GSL::Histogram2d#get_yrange(j)
These methods find the upper and lower range limits of the i-th and j-th bins in the x and y directions of the histogram self.
Ex:
irb(main):030:0> h2 = Histogram2d.new(2, [0, 2], 3, [1, 4]) irb(main):031:0> h2.get_xrange(1) => [1.0, 2.0] irb(main):032:0> h2.get_yrange(1) => [2.0, 3.0]
GSL::Histogram2d#xrange
GSL::Histogram2d#yrange
Vector::View
objects.GSL::Histogram2d#xmax
GSL::Histogram2d#xmin
GSL::Histogram2d#ymax
GSL::Histogram2d#ymin
GSL::Histogram2d#nx
GSL::Histogram2d#ny
GSL::Histogram2d#reset
GSL::Histogram2d#find(x, y)
GSL::Histogram2d#max_val
GSL::Histogram2d#max_bin
GSL::Histogram2d#min_val
GSL::Histogram2d#min_bin
GSL::Histogram2d#xmean
GSL::Histogram2d#xsigma
GSL::Histogram2d#ymean
GSL::Histogram2d#ysigma
GSL::Histogram2d#cov
GSL::Histogram2d#sum
GSL::Histogram2d#integral
GSL::Histogram2d#add
GSL::Histogram2d#sub
GSL::Histogram2d#mul
GSL::Histogram2d#div
GSL::Histogram2d#scale(val)
GSL::Histogram2d#shift(val)
GSL::Histogram2d#fwrite(io)
GSL::Histogram2d#fwrite(filename)
GSL::Histogram2d#fread(io)
GSL::Histogram2d#fread(filename)
GSL::Histogram2d#fprintf(io, range_format, bin_format)
GSL::Histogram2d#fprintf(filename, range_format, bin_format)
GSL::Histogram2d#fscanf(io)
GSL::Histogram2d#fscanf(filename)
GSL::Histogram2d#xproject(jstart = 0, jend = ny-1)
GSL::Histogram
object by projecting the 2D histogram
self onto the x-axis over the y-range from jstart to jend.GSL::Histogram2d#yproject(istart = 0, iend = nx-1)
GSL::Histogram
object by projecting the 2D histogram
self onto the y-axis over the x-range from istart to iend.GSL::Histogram2d::Pdf.new(nx, ny)
GSL::Histogram2d::Pdf.alloc(nx, ny)
GSL::Histogram2d::Pdf#init(h)
GSL::Histogram2d::Pdf#sample(r1, r2)
#!/usr/bin/env ruby require("gsl") N = 10000 BINS = 100 rng = Rng.new(2) h2 = Histogram2d.new(BINS, [-5, 5], BINS, [-8, 8]) sig1 = 1.0 sig2 = 2.0 for i in 0...N do r1 = rng.gaussian(sig1) r2 = rng.gaussian(sig2) h2.increment(r1, r2) end hx = h2.xproject hy = h2.yproject printf("%f %f %f %f\n", h2.xsigma, h2.ysigma, hx.sigma, hy.sigma) GSL::graph(hx, hy, "-T X -C -g 3")