All problems
CRPS for Normal Forecast
Problem
Compute the mean continuous ranked probability score for a normal predictive distribution: for each observation y, with z = (y - mu) / sigma, CRPS = sigma * (z * (2*Phi(z) - 1) + 2*phi(z) - 1/sqrt(pi)), where Phi and phi are the standard normal CDF and density.
Return 0.0 for empty observations or non-positive sigma.
Hint
CRPS generalizes absolute error and rewards sharp, calibrated forecasts.
Test cases
case 1
in: [[0],0,1]
expected: 0.23369497725510913
case 2
in: [[1.96],0,1]
expected: 1.414700556138123
case 3
in: [[0,1,-1],0,2]
expected: 0.5976680265098805
case 4
in: [[5],5,0]
expected: 0
Starter codePython
import math
def crps_normal_forecast(observations, mu, sigma):
# Your code here
pass4 test cases · run your code against them in the editor