crps
crps, function
def pure crps(r: ranvar, n: number): number
def pure crps(r1: ranvar, r2: ranvar): number
Computes the Continuous Ranked Probability Score (CRPS). With crps(r, n), the score is between the predictive distribution r and the observed value n. With crps(r1, r2), it is the extended CRPS between two predictive distributions.
r: the predictive distribution to compare to observationn.n: the observed value.r1: the first predictive distribution.r2: the second predictive distribution.
Examples
r = poisson(3)
r1 = poisson(3)
r2 = poisson(7)
show table "CRPS" with
crps(r, 4) as "crps(r, 4)"
crps(r1, r2) as "crps(r1, r2)"
Output:
| crps(r, 4) | crps(r1, r2) |
|---|---|
| 0.6825997 | 1.836925 |
Remarks
The scalar overload crps(r, n) scores the forecast against the exact
observation n. The two-ranvar overload compares their cumulative
distribution functions; it is not the average scalar CRPS obtained by drawing
observations from r2.
Let $X_1$ and $X_2$ be two random variables with cumulative distribution functions $F_1$ and $F_2$. The two-ranvar overload computes:
$$CRPS(X_1, X_2) = \int_{-\infty}^{+\infty} (F_1(x) - F_2(x))^2 dx$$
Do not replace an exact observation with dirac(n) merely to use the
two-ranvar overload. Away from zero, the ranvar’s wider buckets can approximate
the point mass, whereas the scalar observation is not bucketed.