public static double regularisedGammaFunction(double a, double x) {
		if (a < 0.0D || x < 0.0D) throw new IllegalArgumentException("\nFunction defined only for a >= 0 and x>=0");

		boolean oldIgSupress = Stat.igSupress;
		Stat.igSupress = true;
		double igf = 0.0D;

		if (x != 0) {
			if (x < a + 1.0D) {
				// Series representation
				igf = incompleteGammaSer(a, x);
			} else {
				// Continued fraction representation
				igf = incompleteGammaFract(a, x);
			}
			if (igf != igf) igf = 1.0 - Stat.crigfGaussQuad(a, x);
		}
		if (igf < 0.0) igf = 0.0;
		Stat.igSupress = oldIgSupress;
		return igf;
	}