Search in sources :

Example 1 with FastMath

use of org.apache.commons.math3.util.FastMath in project gatk-protected by broadinstitute.

the class HeterogeneousHeterozygousPileupPriorModel method initializeIntegrationQuadrature.

/**
     * Initilizes the quadrature for calculating allele ratio integrals in
     * {@link HeterogeneousHeterozygousPileupPriorModel#getHetLogLikelihood(List)}
     *
     * @param numIntegPoints  number of points in the quadrature
     */
private void initializeIntegrationQuadrature(final int numIntegPoints) {
    /* get Gauss-Legendre quadrature factory of order @numIntegPoints */
    final GaussIntegratorFactory integratorFactory = new GaussIntegratorFactory();
    final GaussIntegrator gaussIntegrator = integratorFactory.legendre(numIntegPoints, minHetAlleleFraction, 1.0 - minHetAlleleFraction);
    /* abscissas */
    gaussIntegrationAbscissas.clear();
    gaussIntegrationAbscissas.addAll(IntStream.range(0, numIntegPoints).mapToDouble(gaussIntegrator::getPoint).boxed().collect(Collectors.toList()));
    /* weights */
    gaussIntegrationWeights.clear();
    gaussIntegrationWeights.addAll(IntStream.range(0, numIntegPoints).mapToDouble(gaussIntegrator::getWeight).boxed().collect(Collectors.toList()));
    /* log of weights */
    gaussIntegrationLogWeights.clear();
    gaussIntegrationLogWeights.addAll(gaussIntegrationWeights.stream().mapToDouble(FastMath::log).boxed().collect(Collectors.toList()));
}
Also used : GaussIntegratorFactory(org.apache.commons.math3.analysis.integration.gauss.GaussIntegratorFactory) GaussIntegrator(org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator)

Example 2 with FastMath

use of org.apache.commons.math3.util.FastMath in project gatk by broadinstitute.

the class HeterogeneousHeterozygousPileupPriorModel method initializeIntegrationQuadrature.

/**
     * Initilizes the quadrature for calculating allele ratio integrals in
     * {@link HeterogeneousHeterozygousPileupPriorModel#getHetLogLikelihood(List)}
     *
     * @param numIntegPoints  number of points in the quadrature
     */
private void initializeIntegrationQuadrature(final int numIntegPoints) {
    /* get Gauss-Legendre quadrature factory of order @numIntegPoints */
    final GaussIntegratorFactory integratorFactory = new GaussIntegratorFactory();
    final GaussIntegrator gaussIntegrator = integratorFactory.legendre(numIntegPoints, minHetAlleleFraction, 1.0 - minHetAlleleFraction);
    /* abscissas */
    gaussIntegrationAbscissas.clear();
    gaussIntegrationAbscissas.addAll(IntStream.range(0, numIntegPoints).mapToDouble(gaussIntegrator::getPoint).boxed().collect(Collectors.toList()));
    /* weights */
    gaussIntegrationWeights.clear();
    gaussIntegrationWeights.addAll(IntStream.range(0, numIntegPoints).mapToDouble(gaussIntegrator::getWeight).boxed().collect(Collectors.toList()));
    /* log of weights */
    gaussIntegrationLogWeights.clear();
    gaussIntegrationLogWeights.addAll(gaussIntegrationWeights.stream().mapToDouble(FastMath::log).boxed().collect(Collectors.toList()));
}
Also used : GaussIntegratorFactory(org.apache.commons.math3.analysis.integration.gauss.GaussIntegratorFactory) GaussIntegrator(org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator)

Aggregations

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