uvex_transients.utils.stat_utils.binned_density#
- uvex_transients.utils.stat_utils.binned_density(values: ArrayLike, edges: ArrayLike, confidence: float = 0.6827) dict[str, NDArray[float64]][source]#
Histogram samples into counts and a probability density, with a confidence interval on each bin.
A bin that holds \(k\) of the \(n\) samples is a binomial proportion \(k/n\), so its interval is the exact one of clopper_pearson_interval. This stays well-behaved in bins with few or no samples, where a Poisson \(\sqrt{k}\) does not. The density is the proportion divided by the width of the bin.
- Parameters:
values (
array-like) – The samples, shape(n,)and finite. Samples outside edges count towards \(n\) but fall in no bin, so the density integrates to less than 1 over a range that does not cover them.edges (
array-like) – Increasing bin edges, shape(B + 1,). The last bin includes its upper edge.confidence (
float, optional) – Confidence level of the intervals. The default is the central 68.27% of a normal distribution.
- Returns:
Arrays of shape
(B,):count(integer) withcount_loandcount_hi, the interval on the count that the same number of samples would give, anddensitywithdensity_loanddensity_hi, in the inverse of the units of values.- Return type:
- Raises:
ValueError – If edges has fewer than two entries or does not increase.