GNU Scientific Library Reference Manual - Third Edition (v1.12)by M. Galassi, J. Davies, J. Theiler, B. Gough, G. Jungman, P. Alken, M. Booth, F. Rossi Paperback (6"x9"), 592 pages, 60 figures ISBN 0954612078 RRP £24.95 ($39.95) |

## 21.16 Updating and accessing 2D histogram elements

You can access the bins of a two-dimensional histogram either by specifying a pair of (x,y) coordinates or by using the bin indices (i,j) directly. The functions for accessing the histogram through (x,y) coordinates use binary searches in the x and y directions to identify the bin which covers the appropriate range.

__Function:__int**gsl_histogram2d_increment***(gsl_histogram2d **`h`, double`x`, double`y`)- 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.

__Function:__int**gsl_histogram2d_accumulate***(gsl_histogram2d **`h`, double`x`, double`y`, double`weight`)- 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`.

__Function:__double**gsl_histogram2d_get***(const gsl_histogram2d **`h`, size_t`i`, size_t`j`)- 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.

__Function:__int**gsl_histogram2d_get_xrange***(const gsl_histogram2d **`h`, size_t`i`, double *`xlower`, double *`xupper`)__Function:__int**gsl_histogram2d_get_yrange***(const gsl_histogram2d **`h`, size_t`j`, double *`ylower`, double *`yupper`)- 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`

.

__Function:__double**gsl_histogram2d_xmax***(const gsl_histogram2d **`h`)__Function:__double**gsl_histogram2d_xmin***(const gsl_histogram2d **`h`)__Function:__size_t**gsl_histogram2d_nx***(const gsl_histogram2d **`h`)__Function:__double**gsl_histogram2d_ymax***(const gsl_histogram2d **`h`)__Function:__double**gsl_histogram2d_ymin***(const gsl_histogram2d **`h`)__Function:__size_t**gsl_histogram2d_ny***(const gsl_histogram2d **`h`)- 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.

__Function:__void**gsl_histogram2d_reset***(gsl_histogram2d **`h`)- This function resets all the bins of the histogram
`h`to zero.

ISBN 0954612078 | GNU Scientific Library Reference Manual - Third Edition (v1.12) | See the print edition |