    Create a 1D histogram from a sequence of samples.

histogram1d(x, x_lo, x_hi)
x - sequence of numbers
x_lo - sequence of numbers
x_hi - sequence of numbers

See the `numpy.histogram` routine for a version with more options.

A simple example, calculating the histogram of 1000 values randomly distributed over [0, 1).

>>> import numpy as np >>> rng = np.random.default_rng() >>> x = rng.random(1000) >>> edges = np.linspace(0, 1, 11) >>> xlo = edges[:-1] >>> xhi = edges[1:] >>> y = histogram1d(x, xlo, xhi)

Given a list of samples, bin them up so that they can be used as the dependent axis (the value to be fitted) in a Sherpa data set:

>>> dataspace1d(1, 10, 1) >>> lo, hi = get_indep() >>> n = histogram1d([2, 3, 2, 8, 5, 2], lo, hi) >>> set_dep(n)

PARAMETERS

The parameters for this function are:

Parameter
Definition
x
The array of samples
x_lo
The lower-edges of each bin.
x_hi
The upper-edges of each bin, which must be the same size as x_lo .

The return value from this function is:

y -- The number of samples in each histogram bin defined by the x_lo and x_hi arrays.

Changes in CIAO

The x_lo and x_hi arguments are no-longer changed (sorted) by this routine.

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

December 2023