private static double fTestBisect(double fProb, double fTestLow, double fTestHigh, int df1, int df2, int endTest) {

		double funcLow = fProb - Stat.fTestProb(fTestLow, df1, df2);
		double funcHigh = fProb - Stat.fTestProb(fTestHigh, df1, df2);
		double fTestMid = 0.0D;
		double funcMid = 0.0;
		int nExtensions = 0;
		int nIter = 1000; // iterations allowed
		double check = fProb * 1e-6; // tolerance for bisection
		boolean test0 = true; // test for extending bracket
		boolean test1 = true; // test for bisection procedure
		while (test0) {
			if (funcLow * funcHigh > 0.0D) {
				if (endTest < 0) {
					nExtensions++;
					if (nExtensions > 100) {
						System.out.println("Class: Stats\nMethod: fTestBisect\nProbability higher than range covered\nF-test value is less than " + fTestLow);
						System.out.println("This value was returned");
						fTestMid = fTestLow;
						test0 = false;
						test1 = false;
					}
					fTestLow /= 10.0D;
					funcLow = fProb - Stat.fTestProb(fTestLow, df1, df2);
				} else {
					nExtensions++;
					if (nExtensions > 100) {
						System.out.println("Class: Stats\nMethod: fTestBisect\nProbability lower than range covered\nF-test value is greater than " + fTestHigh);
						System.out.println("This value was returned");
						fTestMid = fTestHigh;
						test0 = false;
						test1 = false;
					}
					fTestHigh *= 10.0D;
					funcHigh = fProb - Stat.fTestProb(fTestHigh, df1, df2);
				}
			} else {
				test0 = false;
			}

			int i = 0;
			while (test1) {
				fTestMid = (fTestLow + fTestHigh) / 2.0D;
				funcMid = fProb - Stat.fTestProb(fTestMid, df1, df2);
				if (Math.abs(funcMid) < check) {
					test1 = false;
				} else {
					i++;
					if (i > nIter) {
						System.out.println("Class: Stats\nMethod: fTestBisect\nmaximum number of iterations exceeded\ncurrent value of F-test value returned");
						test1 = false;
					}
					if (funcMid * funcHigh > 0) {
						funcHigh = funcMid;
						fTestHigh = fTestMid;
					} else {
						funcLow = funcMid;
						fTestLow = fTestMid;
					}
				}
			}
		}
		return fTestMid;
	}