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


Java CombinatoricsUtils.binomialCoefficientDouble方法代码示例

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


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

示例1: compute

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Override
protected double compute(double value1, double value2) {

	// special case for handling missing values
	if (Double.isNaN(value1) || Double.isNaN(value2)) {
		return Double.NaN;
	}

	if (value1 < 0 || value2 < 0) {
		throw new FunctionInputException("expression_parser.function_non_negative", getFunctionName());
	}
	// This is the common definition for the case for k > n.
	if (value2 > value1) {
		return 0;
	} else {
		return CombinatoricsUtils.binomialCoefficientDouble((int) value1, (int) value2);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:19,代码来源:Binominal.java

示例2: fisherPValue

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/**
 * Compute the p-value corresponding to the computed Fisher g-value.
 * A lower value implies a pattern match, but a decision can only
 * be made once a reasonable threshold is set.
 *
 * @return  the p-value corresponding to the Fisher g-value test.
 */
private double fisherPValue() {

    int N = periodogram.length;
    double fisherG = fisherG();

    int upperLimit = (int) Math.floor(1/fisherG);

    double[] values = new double[upperLimit];
    for(int k=0; k < upperLimit; k++) {
        double binomialCo = CombinatoricsUtils.binomialCoefficientDouble(N, k+1);
        values[k] = Math.pow(-1, k) * binomialCo * Math.pow((1-(k+1)*fisherG), N-1);
    }

    fisherPValue = new Sum().evaluate(values);
    return fisherPValue;

}
 
开发者ID:bcbwilla,项目名称:FourierMC,代码行数:25,代码来源:PatternDetection.java

示例3: probability

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double probability(int x) {
    double ret;
    if (x < 0) {
        ret = 0.0;
    } else {
        ret = CombinatoricsUtils.binomialCoefficientDouble(x +
              numberOfSuccesses - 1, numberOfSuccesses - 1) *
              FastMath.pow(probabilityOfSuccess, numberOfSuccesses) *
              FastMath.pow(1.0 - probabilityOfSuccess, x);
    }
    return ret;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:14,代码来源:PascalDistribution.java

示例4: getDelta

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/**
 * @return the delta parameter of Pybus et al (Node spread statistic)
 * @param intervals the intervals for which the delta parameter is calculated.
 */
public static double getDelta(IntervalList intervals) {
	
	// Assumes ultrametric tree!
	if (!intervals.isCoalescentOnly()) {
		throw new IllegalArgumentException("Assumes ultrametric tree!");
	}
	
	int n = intervals.getIntervalCount();
				
	int numTips = n + 1;
	
	double transTreeDepth = 0.0;
	double cumInts = 0.0;
	double sum = 0.0;
	
	// transform intervals
	for (int j=0; j<n; j++) { // move from tips to root
	
		double transInt = intervals.getInterval(j) *
				CombinatoricsUtils.binomialCoefficientDouble(intervals.getLineageCount(j), 2);
		//intLenCopy[j] = getInterval(j)*getLineageCount(j); // birth-death version

		// don't include the last interval so put this before...
		sum += cumInts;

		// ...incrementing the cumInts
		cumInts += transInt;
		
		transTreeDepth += transInt;
	}
	
	double halfTreeDepth = transTreeDepth / 2.0;
				
	sum *= (1.0/(numTips-2.0));
	double top = halfTreeDepth - sum;
	double bottom = transTreeDepth * Math.sqrt((1.0/(12.0*(numTips-2.0))));

	return (top / bottom);
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:44,代码来源:IntervalList.java

示例5: getInterval

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
default double getInterval(double U, int lineageCount, double timeOfLastCoalescent, double earliestTimeOfFinalCoalescent){
    if(timeOfLastCoalescent>earliestTimeOfFinalCoalescent){
        throw new IllegalArgumentException("Given maximum height is smaller than given final coalescent time");
    }
    final double fullIntegral = getIntegral(timeOfLastCoalescent,
            earliestTimeOfFinalCoalescent);
    final double normalisation = 1-Math.exp(-CombinatoricsUtils.binomialCoefficientDouble(lineageCount, 2)*fullIntegral);
    final double intensity = getIntensity(timeOfLastCoalescent);

    double tmp = -Math.log(1-U*normalisation)/CombinatoricsUtils.binomialCoefficientDouble(lineageCount, 2) + intensity;

    return getInverseIntensity(tmp) - timeOfLastCoalescent;

}
 
开发者ID:armanbilge,项目名称:B3,代码行数:15,代码来源:DemographicFunction.java

示例6: calculateIntervalRateParameter

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/**
 * @return the intensity of coalescences (rate parameter, or inverse scale parameter, of Gamma distribution)
 *         associated to the likelihood for this interval, coalescent or otherwise
 */
public final double calculateIntervalRateParameter(DemographicFunction demogFunction, double width,
                                                   double timeOfPrevCoal, int lineageCount, CoalescentEventType type) {
    final double timeOfThisCoal = width + timeOfPrevCoal;
    final double intervalArea = demogFunction.getIntegral(timeOfPrevCoal, timeOfThisCoal);
    return CombinatoricsUtils.binomialCoefficientDouble(lineageCount, 2) * intervalArea;
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:11,代码来源:OldAbstractCoalescentLikelihood.java

示例7: nChoose2

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
public static double nChoose2(int n) {
	if (n < 2)
		return 0.0;
	else
		return CombinatoricsUtils.binomialCoefficientDouble(n, 2);
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:7,代码来源:MathUtils.java

示例8: calculateIntervalLikelihood

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/**
 * k - number of lineages
 * N - population size
 * kingsman coalescent: interval to next coalescent event x ~ exp(lambda), where lambda = C(k,2) / N
 * Like(x ; lambda) = lambda * exp(-lambda * x)
 * so Like(N) = (C(k,2)/N) * exp(- x * C(k,2)/N)
 * lg(Like(N)) = lg(C(k,2)) - lg(N) -C(k,2) * x/N
 * <p/>
 * When N changes over time N = N(t) we have lambda(t) = C(k,2)/N(t) and the likelihood equation is
 * Like(t) = lambda(t) * exp(- integral_0^t(lambda(x) dx) )
 * <p/>
 * lg(Like(t)) = -C(k,2) * integral_0^t(1/N(x) dx) + lg(C(k,2)/N(t))
 * <p/>
 * For a sample event, the likelihood is for no event until time t, and is just the first term of the above.
 *
 * @param demogFunction  the demographic function
 * @param width          the size of the coalescent interval
 * @param timeOfPrevCoal the time of previous coalescent event (going backwards in time)
 * @param lineageCount   the number of lineages spanning this coalescent interval
 * @param type           the type of coalescent event that this interval is terminated by
 * @return likelihood of a given interval,coalescent or otherwise
 */
public static double calculateIntervalLikelihood(DemographicFunction demogFunction,
                                                 double width, double timeOfPrevCoal, int lineageCount,
                                                 CoalescentEventType type) {
    final double timeOfThisCoal = width + timeOfPrevCoal;

    final double intervalArea = demogFunction.getIntegral(timeOfPrevCoal, timeOfThisCoal);
    final double kchoose2 = CombinatoricsUtils.binomialCoefficientDouble(lineageCount, 2);
    double like = -kchoose2 * intervalArea;

    switch (type) {
        case COALESCENT:
            final double demographic = demogFunction.getLogDemographic(timeOfThisCoal);
            like += -demographic;

            break;
        case NEW_SAMPLE:
            break;
    }

    return like;
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:44,代码来源:OldAbstractCoalescentLikelihood.java

示例9: exactP

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/**
 * Computes \(P(D_{n,m} > d)\) if {@code strict} is {@code true}; otherwise \(P(D_{n,m} \ge
 * d)\), where \(D_{n,m}\) is the 2-sample Kolmogorov-Smirnov statistic. See
 * {@link #kolmogorovSmirnovStatistic(double[], double[])} for the definition of \(D_{n,m}\).
 * <p>
 * The returned probability is exact, implemented by unwinding the recursive function
 * definitions presented in [4] (class javadoc).
 * </p>
 *
 * @param d D-statistic value
 * @param n first sample size
 * @param m second sample size
 * @param strict whether or not the probability to compute is expressed as a strict inequality
 * @return probability that a randomly selected m-n partition of m + n generates \(D_{n,m}\)
 *         greater than (resp. greater than or equal to) {@code d}
 */
public double exactP(double d, int n, int m, boolean strict) {
   return 1 - n(m, n, m, n, calculateIntegralD(d, m, n, strict), strict) /
           CombinatoricsUtils.binomialCoefficientDouble(n + m, m);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:21,代码来源:KolmogorovSmirnovTest.java


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