English: Illustration of the continous ranked probability score (CRPS). Given a sample y and a predicted cumulative distribution F, the CRPS is given by computing the difference between the curves at each point x of the support, squaring it and integrating it over the whole support.
Deutsch: Illustration des kontinuierlichen Rang-Wahrscheinlichkeits-Scores (CRPS). Gegeben ist eine Stichprobe y und eine vorhergesagte kumulative Verteilung F. Der CRPS wird berechnet, indem man die Differenz zwischen den Kurven an jedem Punkt x des Trägers berechnet, diese Differenz quadriert und über den gesamten Träger integriert.
importmatplotlib.pyplotaspltimportnumpyasnp# Define the step functiondefstep_function(x):return0ifx<0else1# Define the sigmoid functiondefsigmoid_function(x):return1/(1+np.exp(-x))# Generate x valuesx_high_res=np.linspace(-10,10,1000)# High resolution for the functionsx_low_res=np.linspace(-10,10,71)# Low resolution for the bars# Calculate y values for both functionsy_step=[step_function(i)foriinx_high_res]y_sigmoid=[sigmoid_function(i)foriinx_high_res]# Plot both functionsplt.plot(x_high_res,y_step,label=r'$\mathbb{1}_{x>y}$')plt.plot(x_high_res,y_sigmoid,label='F')# Create a series of vertical bars to represent the area between the two functionsforiinrange(len(x_low_res)-1):bar_height=abs(sigmoid_function(x_low_res[i])-step_function(x_low_res[i]))bar_width=x_low_res[i+1]-x_low_res[i]ifi!=len(x_low_res)-2elsex_low_res[-1]-x_low_res[-2]plt.bar(x_low_res[i],bar_height,bottom=min(step_function(x_low_res[i]),sigmoid_function(x_low_res[i])),width=bar_width,color='grey',align='edge',alpha=0.5)# Add an annotation for the grey areaplt.annotate('CRPS',xy=(0.75,0.75),xytext=(-3,0.7),arrowprops=dict(facecolor='black',shrink=0.05))# Add labels and titleplt.xlabel('x')#plt.title('Step Function vs Sigmoid Function')plt.legend()# Display the plotplt.show()
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
to share – to copy, distribute and transmit the work
to remix – to adapt the work
Under the following conditions:
attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.