class arraymedian(data, ci=95, sf=3, doprint=False, **kwargs)[source]#

Quickly calculate the median and confidence interval of an array.

The confidence interval defaults to 95%. If an integer is supplied, this is treated as a percentile (e.g. 95=95% CI). If a float is supplied, it’s treated as a quantile (e.g. 0.95=95% CI). If a pair of ints or floats is provided, these are treated as upper and lower percentiles/quantiles. If ‘iqr’ is provided, then print the interquartile range (equivalent to 50% CI). If ‘range’ is provided then print the full range (equivalent to 100% CI).

  • data (array) – the data to summarize

  • ci (int/float/list/str) – the confidence interval to use to use (see above for details)

  • sf (int) – number of significant figures to use

  • doprint (bool) – whether to print (else, return the string)

  • kwargs (dict) – passed to sc.sigfig()


data = [1210, 1072, 1722, 1229, 1902]
sc.printmedian(data, 80) # Returns '1230 (80.0% CI: 1130, 1830)'

New in version 3.0.0.