scoringrules.crps_binomial#
- scoringrules.crps_binomial(obs: ArrayLike, n: ArrayLike, prob: ArrayLike, *, backend: Backend = None) ArrayLike#
Compute the closed form of the CRPS for the binomial distribution.
It is based on the following formulation from [1]:
\[\mathrm{CRPS}(F_{n, p}, y) = 2 \sum_{x = 0}^{n} f_{n,p}(x) (1\{y < x\} - F_{n,p}(x) + f_{n,p}(x)/2) (x - y),\]where \(f_{n, p}\) and \(F_{n, p}\) are the PDF and CDF of the binomial distribution with size parameter \(n = 0, 1, 2, ...\) and probability parameter \(p \in [0, 1]\).
- Parameters:
- obsarray_like
The observed values as an integer or array of integers.
- n: array_like
Size parameter of the forecast binomial distribution as an integer or array of integers.
- probarray_like
Probability parameter of the forecast binomial distribution as a float or array of floats.
- backendstr, optional
The name of the backend used for computations. Defaults to
numbaif available, elsenumpy.
- Returns:
- crps:
The CRPS between Binomial(n, prob) and obs.
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_binomial(4, 10, 0.5) 0.5955772399902344