redback.utils.calc_one_dimensional_median_and_error_bar

redback.utils.calc_one_dimensional_median_and_error_bar(samples, quantiles=(0.16, 0.84), fmt='.2f')[source]

Calculates the median and error bars for a one-dimensional sample array.

This function computes the median, lower, and upper error bars based on the specified quantiles. It returns these values along with a formatted string representation.

Parameters:
  • samples (list or numpy.ndarray) – An array of numerical values representing the sample data. The input must not be empty.

  • quantiles (tuple) – A tuple specifying the lower and upper quantile values. For example, (0.16, 0.84) represents the 16th percentile as the lower quantile and the 84th percentile as the upper quantile. Default is (0.16, 0.84).

  • fmt (str) – A format string for rounding the results in the formatted output. Default is ‘.2f’.

Returns:

A namedtuple containing the median, lower error bar, upper error bar, and a formatted string representation.

Return type:

MedianErrorBarResult

Raises:

ValueError – If the input samples array is empty.