/* returns normal cumulated distribution function */ double normalcdf(double x, double m, double s){ double z = (x - m) / s; if (z >= 0) return 0.5 + 0.5 * gammacdf(z * z / 2, 0.5); else return 0.5 - 0.5 * gammacdf(z * z / 2, 0.5); }
/* returns logarithmic normal cumulated distribution function */ double lognormalcdf(double x, double a, double b) { double z = (log(x) - a) / b; if (x == 0) return 0; if (z >= 0) return 0.5 + 0.5 * gammacdf(z * z / 2, 0.5); else return 0.5 - 0.5 * gammacdf(z * z / 2, 0.5); }
/* chi2cdf: chi-square cumulative distribution function. * @x: the x-value for evaluation. * @k: the number of degrees of freedom. */ double chi2cdf (double x, double k) { /* return the value. */ return gammacdf (x, k / 2.0, 2.0); }