scoringrules.crps_hypergeometric

scoringrules.crps_hypergeometric#

scoringrules.crps_hypergeometric(obs: ArrayLike, m: ArrayLike, n: ArrayLike, k: ArrayLike, *, backend: Backend = None) ArrayLike#

Compute the closed form of the CRPS for the hypergeometric distribution.

It is based on the following formulation from [1]:

\[\mathrm{CRPS}(F_{m, n, k}, y) = 2 \sum_{x = 0}^{n} f_{m,n,k}(x) (1\{y < x\} - F_{m,n,k}(x) + f_{m,n,k}(x)/2) (x - y),\]

where \(f_{m, n, k}\) and \(F_{m, n, k}\) are the PDF and CDF of the hypergeometric distribution with population parameters \(m,n = 0, 1, 2, ...\) and size parameter \(k = 0, ..., m + n\).

Parameters:
obsarray_like

The observed values.

marray_like

Number of success states in the population.

narray_like

Number of failure states in the population.

karray_like

Number of draws, without replacement. Must be in 0, 1, …, m + n.

backendstr, optional

The name of the backend used for computations. Defaults to numba if available, else numpy.

Returns:
crps:

The CRPS between obs and Hypergeometric(m, n, k).

References

[1]

Jordan, A., Krüger, F., & Lerch, S. (2019). Evaluating Probabilistic Forecasts with scoringRules. Journal of Statistical Software, 90(12), 1-37. https://doi.org/10.18637/jss.v090.i12

Examples

>>> import scoringrules as sr
>>> sr.crps_hypergeometric(5, 7, 13, 12)
0.44697415547610597