Search in sources :

Example 6 with GaussIntegrator

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);
}
Also used : GaussIntegrator(org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator)

Aggregations

GaussIntegrator (org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator)6 GaussIntegratorFactory (org.apache.commons.math3.analysis.integration.gauss.GaussIntegratorFactory)2