// revised Feb. 9, 1998 -------- C functions for calculating the NSA Ratings Curve ----- (Also available at ) // C functions for calculating the NSA Ratings Curve // (The cumulative normal distribution) // To find P(Win|Rating1,Rating2), as used in the NSA ratings // formula (as of Jan. 10, 1998), call // NSARatingsCurve(Rating1-Rating2) double NSARatingsCurve(double diff) { if (diff > 700) diff= 700; if (diff < -700) diff=-700; return(CumNormal(diff,0,200*sqrt(2))); } double CumNormal(double x, double mean, double stddev) // The cumulative normal distribution { return(CumStandardNormal((x-mean)/stddev)); } double CumStandardNormal(double x) // The cumulative standard normal distribution { return( (1.0 - 0.5*erfcc(x/sqrt(2.0))) ); } // erfcc() from the book __Numerical Recipes__ // Press, Flannery, Teukolsky, & Vetterling, // Cambridge University Press, Cambridge, 1988 // // // erfcc() constants: #define ERFCC_1 -1.26551223 #define ERFCC_2 1.00002368 #define ERFCC_3 0.37409196 #define ERFCC_4 0.09678418 #define ERFCC_5 -0.18628806 #define ERFCC_6 0.27886807 #define ERFCC_7 -1.13520398 #define ERFCC_8 1.48851587 #define ERFCC_9 -0.82215223 #define ERFCC_10 0.17087277 double erfcc(double x) // from the book __Numerical Recipes__ // modified by Robert L. Parker { double t,z,ans; z=fabs(x); t=1.0/(1.0+0.5*z); ans=t*exp(-z*z+ERFCC_1+t* (ERFCC_2+t* (ERFCC_3+t* (ERFCC_4+t* (ERFCC_5+t* (ERFCC_6+t* (ERFCC_7+t* (ERFCC_8+t* (ERFCC_9+t* ERFCC_10))))))))); return x >= 0.0 ? ans : 2.0-ans; }