当前位置: 首页>>代码示例>>Java>>正文


Java GaussIntegrator类代码示例

本文整理汇总了Java中org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator的典型用法代码示例。如果您正苦于以下问题:Java GaussIntegrator类的具体用法?Java GaussIntegrator怎么用?Java GaussIntegrator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GaussIntegrator类属于org.apache.commons.math3.analysis.integration.gauss包,在下文中一共展示了GaussIntegrator类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stage

import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator; //导入依赖的package包/类
/**
 * Compute the n-th stage integral.
 *
 * @param n Number of steps.
 * @return the value of n-th stage integral.
 * @throws TooManyEvaluationsException if the maximum number of evaluations
 * is exceeded.
 */
private double stage(final int n)
    throws TooManyEvaluationsException {
    // Function to be integrated is stored in the base class.
    final UnivariateFunction f = new UnivariateFunction() {
            public double value(double x)
                throws MathIllegalArgumentException, TooManyEvaluationsException {
                return computeObjectiveValue(x);
            }
        };

    final double min = getMin();
    final double max = getMax();
    final double step = (max - min) / n;

    double sum = 0;
    for (int i = 0; i < n; i++) {
        // Integrate over each sub-interval [a, b].
        final double a = min + i * step;
        final double b = a + step;
        final GaussIntegrator g = FACTORY.legendreHighPrecision(numberOfPoints, a, b);
        sum += g.integrate(f);
    }

    return sum;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:34,代码来源:IterativeLegendreGaussIntegrator.java

示例2: integrate2d

import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator; //导入依赖的package包/类
public static double integrate2d(final ToDoubleBiFunction<Double, Double> getIntegrand,
                          final double xLowerBound, final double xUpperBound, final int xNumPoints,
                          final double yLowerBound, final double yUpperBound, final int yNumPoints){
    final GaussIntegrator xIntegrator = integratorFactory.legendre(xNumPoints, xLowerBound, xUpperBound);
    final GaussIntegrator yIntegrator = integratorFactory.legendre(yNumPoints, yLowerBound, yUpperBound);

    final double[] xIntegrationWeights = new IndexRange(0, xNumPoints).mapToDouble(xIntegrator::getWeight);
    final double[] xAbscissas = new IndexRange(0, xNumPoints).mapToDouble(xIntegrator::getPoint);

    final double[] yIntegrationWeights = new IndexRange(0, yNumPoints).mapToDouble(yIntegrator::getWeight);
    final double[] yAbscissas = new IndexRange(0, yNumPoints).mapToDouble(yIntegrator::getPoint);

    double integral = 0;
    for (int i = 0; i < xNumPoints; i++) {
        final double x = xAbscissas[i];
        for (int j = 0; j < yNumPoints; j++) {
            final double y = yAbscissas[j];
            final double integrand = getIntegrand.applyAsDouble(x, y);
            integral += xIntegrationWeights[i] * yIntegrationWeights[j] * integrand;
        }
    }

    return integral;
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:25,代码来源:IntegrationUtils.java

示例3: initializeIntegrationQuadrature

import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator; //导入依赖的package包/类
/**
 * 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()));
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:28,代码来源:HeterogeneousHeterozygousPileupPriorModel.java

示例4: stage

import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator; //导入依赖的package包/类
/**
 * Compute the n-th stage integral.
 *
 * @param n Number of steps.
 * @return the value of n-th stage integral.
 * @throws TooManyEvaluationsException if the maximum number of evaluations
 * is exceeded.
 */
private double stage(final int n)
    throws TooManyEvaluationsException {
    // Function to be integrated is stored in the base class.
    final UnivariateFunction f = new UnivariateFunction() {
            public double value(double x) {
                return computeObjectiveValue(x);
            }
        };

    final double min = getMin();
    final double max = getMax();
    final double step = (max - min) / n;

    double sum = 0;
    for (int i = 0; i < n; i++) {
        // Integrate over each sub-interval [a, b].
        final double a = min + i * step;
        final double b = a + step;
        final GaussIntegrator g = FACTORY.legendreHighPrecision(numberOfPoints, a, b);
        sum += g.integrate(f);
    }

    return sum;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:33,代码来源:IterativeLegendreGaussIntegrator.java

示例5: stage

import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator; //导入依赖的package包/类
/**
 * Compute the n-th stage integral.
 *
 * @param n Number of steps.
 * @return the value of n-th stage integral.
 * @throws TooManyEvaluationsException if the maximum number of evaluations
 * is exceeded.
 */
private double stage(final int n)
    throws TooManyEvaluationsException {
    // Function to be integrated is stored in the base class.
    final UnivariateFunction f = new UnivariateFunction() {
            /** {@inheritDoc} */
            public double value(double x)
                throws MathIllegalArgumentException, TooManyEvaluationsException {
                return computeObjectiveValue(x);
            }
        };

    final double min = getMin();
    final double max = getMax();
    final double step = (max - min) / n;

    double sum = 0;
    for (int i = 0; i < n; i++) {
        // Integrate over each sub-interval [a, b].
        final double a = min + i * step;
        final double b = a + step;
        final GaussIntegrator g = FACTORY.legendreHighPrecision(numberOfPoints, a, b);
        sum += g.integrate(f);
    }

    return sum;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:35,代码来源:IterativeLegendreGaussIntegrator.java

示例6: integrate

import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator; //导入依赖的package包/类
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);
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:13,代码来源:IntegrationUtils.java

示例7: integrate

import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator; //导入依赖的package包/类
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 MathUtils.dotProduct(gaussIntegrationWeights, integrands);
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:13,代码来源:IntegrationUtils.java


注:本文中的org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。