errorbar_hist

hep_spt.errorbar_hist(arr, bins=20, range=None, weights=None, norm=False, norm_type='range', uncert=None)[source]

Calculate the values needed to create an error bar histogram. Different errors can be considered (see below).

Parameters
  • arr – input array of data to process.

  • bins (int or sequence of scalars or str) – see numpy.histogram().

  • range (None or tuple(float, float)) – range to process in the input array.

  • weights (None or numpy.ndarray(value-type)) – possible weights for the histogram.

  • norm (bool, int or float) – if True, normalize the histogram. If it is set to a number, the histogram is normalized and multiplied by that number.

  • norm_type (str) – the normalization type to apply. To be chosen between ‘range’ and ‘all’. In the first case (default), only the points lying inside the histogram range are considered in the normalization. In the later, all the points are considered. In this case, the sum of the values returned by this function will not sum the value provided in “norm”.

  • uncert (str or None) – type of uncertainty to consider. If None, the square root of the sum of squared weights is considered. The possibilities are: - “freq”: frequentist uncertainties. - “dll”: uncertainty based on the difference on the logarithm of likelihood. - “sw2”: sum of square of weights. In case of non-weighted data, the uncertainties will be equal to the square root of the entries in the bin.

Returns

Values, edges, the spacing between bins in X the Y errors. In the non-weighted case, errors in Y are returned as two arrays, with the lower and upper uncertainties.

Return type

numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray

Raises
  • ValueError – if the uncertainty type is not among the possibilities.

  • ValueError – if the normalization type is neither ‘range’ nor ‘all’.

  • TypeError – if the uncertainty is “freq” or “dll” and “weights” is not of integer type.

See also

hep_spt.stats.poisson_fu(), hep_spt.stats.poisson_llu()