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


Java CombinatoricsUtils.factorial方法代码示例

本文整理汇总了Java中org.apache.commons.math3.util.CombinatoricsUtils.factorial方法的典型用法代码示例。如果您正苦于以下问题:Java CombinatoricsUtils.factorial方法的具体用法?Java CombinatoricsUtils.factorial怎么用?Java CombinatoricsUtils.factorial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.util.CombinatoricsUtils的用法示例。


在下文中一共展示了CombinatoricsUtils.factorial方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Orthogonality

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/**
 * Tests if orthogonality relation regarding a fixed l holds true for all l between 0 and 5.
 */
@Test
@DisplayName("Test Orthogonality (l)")
public void testOrthogonalityL() {
    final double dx = 1e-4;
    for (int l1=0;l1<=5;l1++) {
        for (int l2=0;l2<=5;l2++) {
            for (int m=0;m<=l1 && m<=l2;m++) {
                final AssociatedLegendrePolynomial alp1 = new AssociatedLegendrePolynomial(l1,m);
                final AssociatedLegendrePolynomial alp2 = new AssociatedLegendrePolynomial(l2,m);
                double result = 0.0;
                final double expected = (2.0)/(2*l1+1) * ((double)CombinatoricsUtils.factorial(l1+m)/(double)CombinatoricsUtils.factorial(l1-m)) * MathHelper.kronecker(l1,l2);
                for (double x = -1.0; x <= 1.0; x+=dx) {
                    result += (alp1.value(x) * alp2.value(x)) * dx;
                }
                assertEquals(expected, result,  1e-3);
            }
        }

    }
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:24,代码来源:AssociatedLegendrePolynomialTest.java

示例2: taylor

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/** Evaluate Taylor expansion of a derivative structure.
 * @param ds array holding the derivative structure
 * @param dsOffset offset of the derivative structure in its array
 * @param delta parameters offsets (&Delta;x, &Delta;y, ...)
 * @return value of the Taylor expansion at x + &Delta;x, y + &Delta;y, ...
 * @throws MathArithmeticException if factorials becomes too large
 */
public double taylor(final double[] ds, final int dsOffset, final double ... delta)
   throws MathArithmeticException {
    double value = 0;
    for (int i = getSize() - 1; i >= 0; --i) {
        final int[] orders = getPartialDerivativeOrders(i);
        double term = ds[dsOffset + i];
        for (int k = 0; k < orders.length; ++k) {
            if (orders[k] > 0) {
                try {
                    term *= FastMath.pow(delta[k], orders[k]) /
                    CombinatoricsUtils.factorial(orders[k]);
                } catch (NotPositiveException e) {
                    // this cannot happen
                    throw new MathInternalError(e);
                }
            }
        }
        value += term;
    }
    return value;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:29,代码来源:DSCompiler.java

示例3: testReciprocal

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testReciprocal() {
    for (double x = 0.1; x < 1.2; x += 0.1) {
        DerivativeStructure r = new DerivativeStructure(1, 6, 0, x).reciprocal();
        Assert.assertEquals(1 / x, r.getValue(), 1.0e-15);
        for (int i = 1; i < r.getOrder(); ++i) {
            double expected = ArithmeticUtils.pow(-1, i) * CombinatoricsUtils.factorial(i) /
                              FastMath.pow(x, i + 1);
            Assert.assertEquals(expected, r.getPartialDerivative(i), 1.0e-15 * FastMath.abs(expected));
        }
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:13,代码来源:DerivativeStructureTest.java

示例4: testLog

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Override
@Test
public void testLog() {
    double[] epsilon = new double[] { 1.0e-16, 1.0e-16, 3.0e-14, 7.0e-13, 3.0e-11 };
    for (int maxOrder = 0; maxOrder < 5; ++maxOrder) {
        for (double x = 0.1; x < 1.2; x += 0.001) {
            DerivativeStructure log = new DerivativeStructure(1, maxOrder, 0, x).log();
            Assert.assertEquals(FastMath.log(x), log.getValue(), epsilon[0]);
            for (int n = 1; n <= maxOrder; ++n) {
                double refDer = -CombinatoricsUtils.factorial(n - 1) / FastMath.pow(-x, n);
                Assert.assertEquals(refDer, log.getPartialDerivative(n), epsilon[n]);
            }
        }
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:16,代码来源:DerivativeStructureTest.java

示例5: eventsArrivalProbability

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/**
 * Gets the probability to arrive {@link #getK() K} events in the current time,
 * considering the expected average arrival time {@link #getLambda() lambda}.
 * It computes the Probability Mass Function (PMF) of the Poisson distribution.
 * @return
 * @see <a href="https://en.wikipedia.org/wiki/Poisson_distribution">Poisson distribution</a>
 */
public double eventsArrivalProbability(){
    return (Math.pow(getLambda(), k) * Math.exp(-getLambda())) / CombinatoricsUtils.factorial(k);
}
 
开发者ID:manoelcampos,项目名称:cloudsim-plus,代码行数:11,代码来源:PoissonDistr.java


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