hist_Xd

Builds one-, two- or three dimensional histogram of values with equal bin width.

Syntax

h = hist_1d(x, x_min, x_max, x_bins)
h = hist_1d(x, x_min, x_max, x_bins, type)

h = hist_2d(x, x_min, x_max, x_bins, y)
h = hist_2d(x, x_min, x_max, x_bins, y, type)
h = hist_2d(x, x_min, x_max, x_bins,...
            y, y_min, y_max, y_bins)
h = hist_2d(x, x_min, x_max, x_bins,...
            y, y_min, y_max, y_bins, type)

h = hist_3d(x, x_min, x_max, x_bins, y, z)
h = hist_3d(x, x_min, x_max, x_bins, y, z, type)
h = hist_3d(x, x_min, x_max, x_bins,...
            y,...
            z, z_min, z_max, z_bins)
h = hist_3d(x, x_min, x_max, x_bins,...
            y,...
            z, z_min, z_max, z_bins, type)
h = hist_3d(x, x_min, x_max, x_bins,...
            y, y_min, y_max, y_bins,...
            z, z_min, z_max, z_bins)
h = hist_3d(x, x_min, x_max, x_bins,...
            y, y_min, y_max, y_bins, ...
            z, z_min, z_max, z_bins, type)

Description

hist_1d builds one-dimensional histogram of the values x in the half-closed interval [x_min, x_max) that is split into x_bins equally sized bins.

hist_2d build two-dimensional histogram of the values x and y in half-closed intervals [x_min, x_max) for x and [y_min, y_max) for y split into x_bins and y_bins respectively.

hist_3d build three-dimensional histogram of the values x, y and z in half-closed intervals [x_min, x_max) for x, [y_min, y_max) for y and [z_min, z_max) for z split into x_bins, y_bins and z_bins respectively.

Parameters

x, y, z

Vectors of numeric values of the same numeric type to form the histogram.

x_min, x_max, x_bins

Numeric values defining the histogram interval for values x.

y_min, y_may, y_bins

Numeric values defining the histogram interval for values y.

z_min, z_maz, z_bins

Numeric values defining the histogram interval for values z.

type

String value that defines the resulting histogram type. Supported types are: uint8, uint16, uint32, int8,int16, int32, single and double

Return values

Returns a histogram as a vector of numeric values.

Examples

In this example the function count the number of events falling into the intervals [2, 3) and [3, 4]. From the input vector only value 2 falls into the first bin and two values (3 and 3.4) are inside the second interval.

>> photonscore.hist_1d([1 2 3 3.4 5 10], 2, 4, 2)

ans =

     1
     2

Here we build a histogram of normally distributed values in a range [-3, 3) with 100 bins.

>> x = -3:0.06:2.94;
>> h = photonscore.hist_1d(randn(1000, 1), -3, 3, 100);
>> stairs(x, h)

Gaussian distribution

This example uses 10000 normally distributed values for x values and distorted for y.

>> x = randn(10000, 1);
>> y = randn(10000, 1)/3 + x.^3/3;
>> imagesc(photonscore.hist_2d(x, -3, 3, 100, y))
>> colorbar

Distorted 2D gaussian distribution