- sherpa.utils.histogram1d(x, x_lo, x_hi)
Create a 1D histogram from a sequence of samples.
numpy.histogramroutine for a version with more options.
x (sequence of numbers) – The array of samples
x_lo (sequence of numbers) – The lower-edges of each bin.
x_hi (sequence of numbers) – The upper-edges of each bin, which must be the same size as
y – The number of samples in each histogram bin defined by the
- Return type
A simple example, calculating the histogram of 1000 values randomly distributed over [0, 1).
>>> x = np.random.random(1000) >>> edges = np.arange(0, 1.1, 0.1) >>> xlo = edges[:-1] >>> xhi = edges[1:] >>> y = histogram1d(x, xlo, xhi)
Given a list of samples (
vals), bin them up so that they can be used as the dependent axis (the value to be fitted) in a Sherpa data set:
>>> dataspace1d(0.1, 10, 0.1) >>> (lo, hi) = get_indep() >>> n = histogram1d(vals, lo, hi) >>> set_dep(n)