List of usage examples for org.apache.commons.math3.util ArithmeticUtils binomialCoefficientLog
public static double binomialCoefficientLog(final int n, final int k) throws NotPositiveException, NumberIsTooLargeException, MathArithmeticException
From source file:mastodon.algorithms.MHLinearAlgorithm.java
private void setupIterations() { //choose how many iterations to allocate to each "round" of pruning stepIterations = new double[maxPrunedSpeciesCount]; for (int i = minPrunedSpeciesCount - 1; i < maxPrunedSpeciesCount; i++) { stepIterations[i] = ArithmeticUtils.binomialCoefficientLog(bts.getTaxaCount(), i + 1); }//ww w . j ava 2 s. co m double sum = 0.0; for (double d : stepIterations) { sum += d; } // if ((iterations[0] / sum * totalIterations) > bts.getTaxaCount()) { // double temp = iterations[0]; // iterations[0] = bts.getTaxaCount(); // for(int i = minPrunedSpeciesCount; i < maxPrunedSpeciesCount; i++) { //might want to fill in spots below minPrun.. with 0's // //need to check if temp gives the correct solution here but it's a "lost hope function" anyway // iterations[i] = iterations[i] / (sum - temp) * (totalIterations - bts.getTaxaCount()); // } // } else { for (int i = minPrunedSpeciesCount - 1; i < maxPrunedSpeciesCount; i++) { stepIterations[i] = (int) (stepIterations[i] / sum * totalIterations); } // } }
From source file:mastodon.algorithms.SALinearAlgorithm.java
private void setupIterations() { //choose how many iterations to allocate to each "round" of pruning stepIterations = new double[maxPrunedSpeciesCount]; for (int i = minPrunedSpeciesCount - 1; i < maxPrunedSpeciesCount; i++) { stepIterations[i] = ArithmeticUtils.binomialCoefficientLog(bts.getTaxaCount(), i + 1); }//from w w w . j ava 2 s . com double sum = 0.0; for (double d : stepIterations) { sum += d; } for (int i = minPrunedSpeciesCount - 1; i < maxPrunedSpeciesCount; i++) { stepIterations[i] = (int) (stepIterations[i] / sum * totalIterations); } }