Okay so that actually seemed to work and fixed that problem. Though how come I find that every time I fix one thing I break two others. Basically I had to change everything in the methods calling factorial to use a BigInteger, which worked fine when everything was a BigInteger. Seems to be causing me problems when I'm multiplying/dividing by doubles and such even though I converted the BigInteger to a double. Does anyone see anything wrong with either of these?
Code:
public static double calcProbability(int x, int n, double p) {
return Factorial.calcFactorial(n).divide(
Factorial.calcFactorial(x).multiply(
Factorial.calcFactorial(n - x))).doubleValue()
* Math.pow(p, x) * Math.pow(1 - p, n - x);
}
Code:
public static double calcProbability(int x, double lambda) {
return new BigDecimal(String.valueOf((Math.pow(lambda, x) * Math.pow(
Math.E, lambda * -1)))).divide(
new BigDecimal((Factorial.calcFactorial(x)))).doubleValue();
}