Class: Numo::GSL::Histogram2D

Inherits:
Object
  • Object
show all
Defined in:
ext/numo/gsl/histogram/gsl_histogram.c

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(nx, ny) ⇒ Object

allocate instance of Histogram2D class.

This function allocates memory for a two-dimensional histogram with nx bins in the x direction and ny bins in the y direction. The function returns a pointer to a newly created gsl_histogram2d struct. If insufficient memory is available a null pointer is returned and the error handler is invoked with an error code of GSL_ENOMEM. The bins and ranges must be initialized with one of the functions below before the histogram is ready for use.

Parameters:

  • nx (Integer)

    parameter

  • ny (Integer)

    parameter



1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1229

static VALUE
histogram2d_s_new(VALUE klass, VALUE v1, VALUE v2)
{
    gsl_histogram2d *w;
    w = gsl_histogram2d_alloc(NUM2SIZET(v1), NUM2SIZET(v2));
    if (!w) {
        rb_raise(rb_eNoMemError,"fail to allocate struct");
    }
    return TypedData_Wrap_Struct(cHistogram2D, &histogram2d_data_type, (void*)w);
}

Instance Method Details

#accumulate(x, y, weight) ⇒ Histogram2D

This function is similar to gsl_histogram2d_increment but increases the value of the appropriate bin in the histogram h by the floating-point number weight.

Parameters:

  • x (DFloat)
  • y (DFloat)
  • weight (DFloat)

Returns:



1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1410

static VALUE
histogram2d_accumulate(VALUE self, VALUE v1, VALUE v2, VALUE v3)
{
    gsl_histogram2d *w;
    ndfunc_arg_in_t ain[3] = {{cDF,0},{cDF,0},{cDF,0}};
    ndfunc_t ndf = {iter_histogram2d_accumulate, STRIDE_LOOP, 3,0, ain,0};

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    na_ndloop3(&ndf, w, 3, v1, v2, v3);
    return self;
}

#add(h2) ⇒ Bool

This function adds the contents of the bins in histogram h2 to the corresponding bins of histogram h1, i.e. h’_1(i,j) = h_1(i,j) + h_2(i,j). The two histograms must have identical bin ranges.

Parameters:

Returns:

  • (Bool)


1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1989

static VALUE
histogram2d_add(VALUE self, VALUE v1)
{
    int stat;
    gsl_histogram2d *w, *w1;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);
    TypedData_Get_Struct(v1, gsl_histogram2d, &histogram2d_data_type, w1);

    stat = gsl_histogram2d_add(w, w1);
    return (stat) ? Qtrue: Qfalse;
}

#binDFloat

returns bin field in gsl_histogram2d struct.

Returns:

  • (DFloat)

    narray of bin field in gsl_histogram2d.



1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1188

static VALUE
histogram2d_bin(VALUE self)
{
    gsl_histogram2d *w;
    double *d;
    VALUE v;
    size_t n, i, shape[2];

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    
    n = w->nx * w->ny;
    shape[0] = w->nx;
    shape[1] = w->ny;
    

    v = rb_narray_new(cDF, 2, shape);
    d = (double*)na_get_pointer_for_write(v);
    for (i=0; i<n; i++) {
        d[i] = w->bin[i];
    }
    return v;
}

#covFloat

This function returns the covariance of the histogrammed x and y variables, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation.

Returns:

  • (Float)


1925
1926
1927
1928
1929
1930
1931
1932
1933
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1925

static VALUE
histogram2d_cov(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_cov(w));
}

#div(h2) ⇒ Bool

This function divides the contents of the bins of histogram h1 by the contents of the corresponding bins in histogram h2, i.e. h’_1(i,j) = h_1(i,j) / h_2(i,j). The two histograms must have identical bin ranges.

Parameters:

Returns:

  • (Bool)


2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 2064

static VALUE
histogram2d_div(VALUE self, VALUE v1)
{
    int stat;
    gsl_histogram2d *w, *w1;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);
    TypedData_Get_Struct(v1, gsl_histogram2d, &histogram2d_data_type, w1);

    stat = gsl_histogram2d_div(w, w1);
    return (stat) ? Qtrue: Qfalse;
}

#equal_bins_p(h2) ⇒ Bool

This function returns 1 if all the individual bin ranges of the two histograms are identical, and 0 otherwise.

Parameters:

Returns:

  • (Bool)


1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1964

static VALUE
histogram2d_equal_bins_p(VALUE self, VALUE v1)
{
    int stat;
    gsl_histogram2d *w, *w1;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);
    TypedData_Get_Struct(v1, gsl_histogram2d, &histogram2d_data_type, w1);

    stat = gsl_histogram2d_equal_bins_p(w, w1);
    return (stat) ? Qtrue: Qfalse;
}

#get(i, j) ⇒ Histogram2D

This function returns the contents of the (i,j)-th bin of the histogram h. If (i,j) lies outside the valid range of indices for the histogram then the error handler is called with an error code of GSL_EDOM and the function returns 0.

Parameters:

  • i (Int32/64)
  • j (Int32/64)

Returns:



1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1470

static VALUE
histogram2d_get(VALUE self, VALUE v1, VALUE v2)
{
    gsl_histogram2d *w;
    ndfunc_arg_in_t ain[2] = {{cSSZ,0},{cSSZ,0}};
    ndfunc_arg_out_t aout[1] = {{cDF,0}};
    ndfunc_t ndf = {iter_histogram2d_get, STRIDE_LOOP|NDF_EXTRACT, 2,1, ain,aout};

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return na_ndloop3(&ndf, w, 2, v1, v2);
}

#get_xrange(i) ⇒ Array

These functions find the upper and lower range limits of the i-th and j-th bins in the x and y directions of the histogram h. The range limits are stored in xlower and xupper or ylower and yupper. The lower limits are inclusive (i.e. events with these coordinates are included in the bin) and the upper limits are exclusive (i.e. events with the value of the upper limit are not included and fall in the neighboring higher bin, if it exists). The functions return 0 to indicate success. If i or j lies outside the valid range of indices for the histogram then the error handler is called with an error code of GSL_EDOM.

Parameters:

  • i (Int32/64)

    Int32/64 NArray

Returns:

  • (Array)

    array of [[DFloat] xlower, [DFloat] xupper]



1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1532

static VALUE
histogram2d_get_xrange(VALUE self, VALUE v1)
{
    gsl_histogram2d *w;
    ndfunc_arg_in_t ain[1] = {{cSSZ,0}};
    ndfunc_arg_out_t aout[2] = {{cDF,0},{cDF,0}};
    ndfunc_t ndf = {iter_histogram2d_get_xrange, STRIDE_LOOP|NDF_EXTRACT, 1,2, ain,aout};

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return na_ndloop3(&ndf, w, 1, v1);
}

#get_yrange(j) ⇒ Array

These functions find the upper and lower range limits of the i-th and j-th bins in the x and y directions of the histogram h. The range limits are stored in xlower and xupper or ylower and yupper. The lower limits are inclusive (i.e. events with these coordinates are included in the bin) and the upper limits are exclusive (i.e. events with the value of the upper limit are not included and fall in the neighboring higher bin, if it exists). The functions return 0 to indicate success. If i or j lies outside the valid range of indices for the histogram then the error handler is called with an error code of GSL_EDOM.

Parameters:

  • j (Int32/64)

    Int32/64 NArray

Returns:

  • (Array)

    array of [[DFloat] ylower, [DFloat] yupper]



1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1594

static VALUE
histogram2d_get_yrange(VALUE self, VALUE v1)
{
    gsl_histogram2d *w;
    ndfunc_arg_in_t ain[1] = {{cSSZ,0}};
    ndfunc_arg_out_t aout[2] = {{cDF,0},{cDF,0}};
    ndfunc_t ndf = {iter_histogram2d_get_yrange, STRIDE_LOOP|NDF_EXTRACT, 1,2, ain,aout};

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return na_ndloop3(&ndf, w, 1, v1);
}

#increment(x, y) ⇒ Histogram2D

This function updates the histogram h by adding one (1.0) to the bin whose x and y ranges contain the coordinates (x,y).

If the point (x,y) lies inside the valid ranges of the histogram then the function returns zero to indicate success. If (x,y) lies outside the limits of the histogram then the function returns GSL_EDOM, and none of the bins are modified. The error handler is not called, since it is often necessary to compute histograms for a small range of a larger dataset, ignoring any coordinates outside the range of interest.

Parameters:

  • x (DFloat)
  • y (DFloat)

Returns:



1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1361

static VALUE
histogram2d_increment(VALUE self, VALUE v1, VALUE v2)
{
    gsl_histogram2d *w;
    ndfunc_arg_in_t ain[2] = {{cDF,0},{cDF,0}};
    ndfunc_t ndf = {iter_histogram2d_increment, STRIDE_LOOP, 2,0, ain,0};

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    na_ndloop3(&ndf, w, 2, v1, v2);
    return self;
}

#max_binArray

This function finds the indices of the bin containing the maximum value in the histogram h and stores the result in (i,j). In the case where several bins contain the same maximum value the first bin found is returned.

Returns:

  • (Array)

    array of [h,i]



1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1779

static VALUE
histogram2d_max_bin(VALUE self)
{
    size_t i, j;
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    gsl_histogram2d_max_bin(w, &i, &j);
    return rb_assoc_new(SIZET2NUM(i), SIZET2NUM(j));
}

#max_valFloat

This function returns the maximum value contained in the histogram bins.

Returns:

  • (Float)


1758
1759
1760
1761
1762
1763
1764
1765
1766
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1758

static VALUE
histogram2d_max_val(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_max_val(w));
}

#memcpy(src) ⇒ Bool

This function copies the histogram src into the pre-existing histogram dest, making dest into an exact copy of src. The two histograms must be of the same size.

Parameters:

Returns:

  • (Bool)


1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1308

static VALUE
histogram2d_memcpy(VALUE self, VALUE v1)
{
    int stat;
    gsl_histogram2d *w, *w1;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);
    TypedData_Get_Struct(v1, gsl_histogram2d, &histogram2d_data_type, w1);

    stat = gsl_histogram2d_memcpy(w, w1);
    return (stat) ? Qtrue: Qfalse;
}

#min_binArray

This function finds the indices of the bin containing the minimum value in the histogram h and stores the result in (i,j). In the case where several bins contain the same maximum value the first bin found is returned.

Returns:

  • (Array)

    array of [h,i]



1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1820

static VALUE
histogram2d_min_bin(VALUE self)
{
    size_t i, j;
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    gsl_histogram2d_min_bin(w, &i, &j);
    return rb_assoc_new(SIZET2NUM(i), SIZET2NUM(j));
}

#min_valFloat

This function returns the minimum value contained in the histogram bins.

Returns:

  • (Float)


1799
1800
1801
1802
1803
1804
1805
1806
1807
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1799

static VALUE
histogram2d_min_val(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_min_val(w));
}

#mul(h2) ⇒ Bool

This function multiplies the contents of the bins of histogram h1 by the contents of the corresponding bins in histogram h2, i.e. h’_1(i,j) = h_1(i,j) * h_2(i,j). The two histograms must have identical bin ranges.

Parameters:

Returns:

  • (Bool)


2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 2039

static VALUE
histogram2d_mul(VALUE self, VALUE v1)
{
    int stat;
    gsl_histogram2d *w, *w1;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);
    TypedData_Get_Struct(v1, gsl_histogram2d, &histogram2d_data_type, w1);

    stat = gsl_histogram2d_mul(w, w1);
    return (stat) ? Qtrue: Qfalse;
}

#nxInteger

These functions return the maximum upper and minimum lower range limits and the number of bins for the x and y directions of the histogram h. They provide a way of determining these values without accessing the gsl_histogram2d struct directly.

Returns:

  • (Integer)


1660
1661
1662
1663
1664
1665
1666
1667
1668
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1660

static VALUE
histogram2d_nx(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return SIZET2NUM(gsl_histogram2d_nx(w));
}

#nyInteger

These functions return the maximum upper and minimum lower range limits and the number of bins for the x and y directions of the histogram h. They provide a way of determining these values without accessing the gsl_histogram2d struct directly.

Returns:

  • (Integer)


1723
1724
1725
1726
1727
1728
1729
1730
1731
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1723

static VALUE
histogram2d_ny(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return SIZET2NUM(gsl_histogram2d_ny(w));
}

#resetObject

This function resets all the bins of the histogram h to zero.



1740
1741
1742
1743
1744
1745
1746
1747
1748
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1740

static VALUE
histogram2d_reset(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);
    gsl_histogram2d_reset(w);
    return Qnil;
}

#scale(scale) ⇒ Qnil

This function multiplies the contents of the bins of histogram h by the constant scale, i.e. $h’_1(i,j) = h_1(i,j) * \hboxscale$ h’_1(i,j) = h_1(i,j) scale.

Parameters:

  • scale (Float)

Returns:

  • (Qnil)


2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 2088

static VALUE
histogram2d_scale(VALUE self, VALUE v1)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    gsl_histogram2d_scale(w, NUM2DBL(v1));
    return Qnil;
}

#set_ranges(xrange[], yrange[]) ⇒ Histogram2D

This function sets the ranges of the existing histogram h using the arrays xrange and yrange of size xsize and ysize respectively. The values of the histogram bins are reset to zero.

Parameters:

  • xrange[] (DFloat)
  • yrange[] (DFloat)

Returns:



1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1253

static VALUE
histogram2d_set_ranges(VALUE self, VALUE v1, VALUE v2)
{
    gsl_histogram2d *w;
    double *p1, *p2;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    v1 = cast_1d_contiguous(v1, cDF);
    p1 = (double*)na_get_pointer_for_read(v1);
    v2 = cast_1d_contiguous(v2, cDF);
    p2 = (double*)na_get_pointer_for_read(v2);

    gsl_histogram2d_set_ranges(w, p1, RNARRAY_SIZE(v1), p2, RNARRAY_SIZE(v2));
    RB_GC_GUARD(v1);
    RB_GC_GUARD(v2);
    return self;
}

#set_ranges_uniform(xmin, xmax, ymin, ymax) ⇒ Qnil

This function sets the ranges of the existing histogram h to cover the ranges xmin to xmax and ymin to ymax uniformly. The values of the histogram bins are reset to zero.

Parameters:

  • xmin (Float)
  • xmax (Float)
  • ymin (Float)
  • ymax (Float)

Returns:

  • (Qnil)


1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1286

static VALUE
histogram2d_set_ranges_uniform(VALUE self, VALUE v1, VALUE v2, VALUE v3, VALUE v4)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    gsl_histogram2d_set_ranges_uniform(w, NUM2DBL(v1),NUM2DBL(v2),NUM2DBL(v3),NUM2DBL(v4));
    return Qnil;
}

#shift(offset) ⇒ Qnil

This function shifts the contents of the bins of histogram h by the constant offset, i.e. $h’_1(i,j) = h_1(i,j) + \hboxoffset$ h’_1(i,j) = h_1(i,j) + offset.

Parameters:

  • offset (Float)

Returns:

  • (Qnil)


2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 2110

static VALUE
histogram2d_shift(VALUE self, VALUE v1)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    gsl_histogram2d_shift(w, NUM2DBL(v1));
    return Qnil;
}

#sub(h2) ⇒ Bool

This function subtracts the contents of the bins in histogram h2 from the corresponding bins of histogram h1, i.e. h’_1(i,j) = h_1(i,j) - h_2(i,j). The two histograms must have identical bin ranges.

Parameters:

Returns:

  • (Bool)


2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 2014

static VALUE
histogram2d_sub(VALUE self, VALUE v1)
{
    int stat;
    gsl_histogram2d *w, *w1;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);
    TypedData_Get_Struct(v1, gsl_histogram2d, &histogram2d_data_type, w1);

    stat = gsl_histogram2d_sub(w, w1);
    return (stat) ? Qtrue: Qfalse;
}

#sumFloat

This function returns the sum of all bin values. Negative bin values are included in the sum.

Returns:

  • (Float)


1944
1945
1946
1947
1948
1949
1950
1951
1952
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1944

static VALUE
histogram2d_sum(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_sum(w));
}

#xmaxFloat

These functions return the maximum upper and minimum lower range limits and the number of bins for the x and y directions of the histogram h. They provide a way of determining these values without accessing the gsl_histogram2d struct directly.

Returns:

  • (Float)


1618
1619
1620
1621
1622
1623
1624
1625
1626
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1618

static VALUE
histogram2d_xmax(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_xmax(w));
}

#xmeanFloat

This function returns the mean of the histogrammed x variable, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation.

Returns:

  • (Float)


1842
1843
1844
1845
1846
1847
1848
1849
1850
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1842

static VALUE
histogram2d_xmean(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_xmean(w));
}

#xminFloat

These functions return the maximum upper and minimum lower range limits and the number of bins for the x and y directions of the histogram h. They provide a way of determining these values without accessing the gsl_histogram2d struct directly.

Returns:

  • (Float)


1639
1640
1641
1642
1643
1644
1645
1646
1647
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1639

static VALUE
histogram2d_xmin(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_xmin(w));
}

#xrangeDFloat

returns xrange field in gsl_histogram2d struct.

Returns:

  • (DFloat)

    narray of xrange field in gsl_histogram2d.



1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1126

static VALUE
histogram2d_xrange(VALUE self)
{
    gsl_histogram2d *w;
    double *d;
    VALUE v;
    size_t n, i, shape[2];

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    
    shape[0] = n = w->nx+1;
    

    v = rb_narray_new(cDF, 2, shape);
    d = (double*)na_get_pointer_for_write(v);
    for (i=0; i<n; i++) {
        d[i] = w->xrange[i];
    }
    return v;
}

#xsigmaFloat

This function returns the standard deviation of the histogrammed x variable, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation.

Returns:

  • (Float)


1883
1884
1885
1886
1887
1888
1889
1890
1891
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1883

static VALUE
histogram2d_xsigma(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_xsigma(w));
}

#ymaxFloat

These functions return the maximum upper and minimum lower range limits and the number of bins for the x and y directions of the histogram h. They provide a way of determining these values without accessing the gsl_histogram2d struct directly.

Returns:

  • (Float)


1681
1682
1683
1684
1685
1686
1687
1688
1689
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1681

static VALUE
histogram2d_ymax(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_ymax(w));
}

#ymeanFloat

This function returns the mean of the histogrammed y variable, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation.

Returns:

  • (Float)


1862
1863
1864
1865
1866
1867
1868
1869
1870
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1862

static VALUE
histogram2d_ymean(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_ymean(w));
}

#yminFloat

These functions return the maximum upper and minimum lower range limits and the number of bins for the x and y directions of the histogram h. They provide a way of determining these values without accessing the gsl_histogram2d struct directly.

Returns:

  • (Float)


1702
1703
1704
1705
1706
1707
1708
1709
1710
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1702

static VALUE
histogram2d_ymin(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_ymin(w));
}

#yrangeDFloat

returns yrange field in gsl_histogram2d struct.

Returns:

  • (DFloat)

    narray of yrange field in gsl_histogram2d.



1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1157

static VALUE
histogram2d_yrange(VALUE self)
{
    gsl_histogram2d *w;
    double *d;
    VALUE v;
    size_t n, i, shape[2];

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    
    shape[0] = n = w->ny+1;
    

    v = rb_narray_new(cDF, 2, shape);
    d = (double*)na_get_pointer_for_write(v);
    for (i=0; i<n; i++) {
        d[i] = w->yrange[i];
    }
    return v;
}

#ysigmaFloat

This function returns the standard deviation of the histogrammed y variable, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation.

Returns:

  • (Float)


1904
1905
1906
1907
1908
1909
1910
1911
1912
# File 'ext/numo/gsl/histogram/gsl_histogram.c', line 1904

static VALUE
histogram2d_ysigma(VALUE self)
{
    gsl_histogram2d *w;

    TypedData_Get_Struct(self, gsl_histogram2d, &histogram2d_data_type, w);

    return DBL2NUM(gsl_histogram2d_ysigma(w));
}