public static double incompleteGammaSer(double a, double x) {
		if (a < 0.0D || x < 0.0D) throw new IllegalArgumentException("\nFunction defined only for a >= 0 and x>=0");
		if (x >= a + 1) throw new IllegalArgumentException("\nx >= a+1   use Continued Fraction Representation");

		double igf = 0.0D;

		if (x != 0.0D) {

			int i = 0;
			boolean check = true;

			double acopy = a;
			double sum = 1.0 / a;
			double incr = sum;
			double loggamma = Stat.logGamma(a);

			while (check) {
				++i;
				++a;
				incr *= x / a;
				sum += incr;
				if (Math.abs(incr) < Math.abs(sum) * Stat.igfeps) {
					igf = sum * Math.exp(-x + acopy * Math.log(x) - loggamma);
					check = false;
				}
				if (i >= Stat.igfiter) {
					check = false;
					igf = Double.NaN;
					if (!Stat.igSupress) {
						System.out.println("\nMaximum number of iterations were exceeded in Stat.incompleteGammaSer().");
						System.out.println("NaN returned.\nIncrement = " + String.valueOf(incr) + ".");
						System.out.println("Sum = " + String.valueOf(sum) + ".\nTolerance =  " + String.valueOf(igfeps));
					}
				}
			}
		}

		return igf;
	}