static double GAMMADIST(double x, double alpha, double beta, bool cumulative) { GammaDistribution dist = new GammaDistribution(alpha, beta); return(cumulative ? dist.CumulativeDistribution(x) : dist.ProbabilityDensity(x)); }