use of org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator in project gatk-protected by broadinstitute.
the class IntegrationUtils method integrate.
public static double integrate(final DoubleFunction<Double> getIntegrand, final double lowerBound, final double upperBound, final int numPoints) {
final GaussIntegrator integrator = integratorFactory.legendre(numPoints, lowerBound, upperBound);
final double[] gaussIntegrationWeights = new IndexRange(0, numPoints).mapToDouble(integrator::getWeight);
final double[] gaussIntegrationAbscissas = new IndexRange(0, numPoints).mapToDouble(integrator::getPoint);
final double[] integrands = MathUtils.applyToArrayInPlace(gaussIntegrationAbscissas, getIntegrand::apply);
return GATKProtectedMathUtils.dotProduct(gaussIntegrationWeights, integrands);
}
Aggregations