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


Java BigFraction.ZERO属性代码示例

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


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

示例1: getMaxNumberOfLocalVotes

public BigFraction getMaxNumberOfLocalVotes() {
    BigFraction result = BigFraction.ZERO;
    for (VotesForCandidate votesForCandidate : voteDistribution.values()) {
        if (result.compareTo(votesForCandidate.getNumberOfVotes()) < 0) {
            result = votesForCandidate.getNumberOfVotes();
        }
    }

    return result;
}
 
开发者ID:BGehrels,项目名称:singleTransferableVoteElections-web,代码行数:10,代码来源:VoteDistributionContentRow.java

示例2: getCumulativeProbability

/**
 * <p>
 * Slightly more efficient than the default getCumulativeProbability
 */
@Override
public BigFraction getCumulativeProbability(int x) {
	if (x >= 1 && x <= sides) {
		return probability.multiply(sides - x + 1);
	} else if (x > sides) {
		return BigFraction.ZERO;
	} else {
		return BigFraction.ONE;
	}
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:14,代码来源:DieDistribution.java

示例3: getProbabilityBounded

@Override
public BigFraction getProbabilityBounded(int x) {
	if (x == 0) {
		return probability.multiply(2);
	} else if (x == 1 || x == 2) {
		return BigFraction.ZERO;
	} else {
		return probability;
	}
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:10,代码来源:DeathZoneDieDistribution.java

示例4: ScaleCumulativeDistribution

private ScaleCumulativeDistribution(Distribution d, Scale s, int newLower,
		int newUpper) {
	// we will be calling getCumulativeProbability(x) a lot
	d = d.cacheCumulative();

	this.lower = newLower;
	this.upper = newUpper;
	final int n = upper - lower;
	this.vals = new BigFraction[n];
	this.cums = new BigFraction[n];
	for (int i = 0, x = lower; x < upper; ++i, ++x) {
		this.cums[i] = s.scale(d.getCumulativeProbability(x), x);
	}

	// initialize the probabilities base on cumulative
	BigFraction last = BigFraction.ZERO;
	for (int i = vals.length - 1; i >= 0; --i) {
		vals[i] = cums[i].subtract(last);
		last = cums[i];

		// not less than zero
		assert (vals[i].compareTo(BigFraction.ZERO) != -1);
		// not greater than one
		assert (vals[i].compareTo(BigFraction.ONE) != 1);
	}

}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:27,代码来源:ScaleCumulativeDistribution.java

示例5: getCumulativeProbability

@Override
public BigFraction getCumulativeProbability(int x) {
	if (x < lower) {
		return BigFraction.ONE;
	} else if (x >= upper) {
		return BigFraction.ZERO;
	} else {
		return cums[x - lower];
	}
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:10,代码来源:ScaleCumulativeDistribution.java

示例6: getProbability

@Override
public BigFraction getProbability(int x) {
	if ((x >= 1 && x < sides) || x == sides + bonus) {
		return probability;
	} else {
		return BigFraction.ZERO;
	}
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:8,代码来源:CritDistribution.java

示例7: getProbability

@Override
public BigFraction getProbability(int x) {
	if (x < lowerBound() || x >= upperBound()) {
		return BigFraction.ZERO;
	} else {
		return getProbabilityBounded(x);
	}
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:8,代码来源:AbstractDistribution.java

示例8: getCumulativeProbability

/**
 * <p>
 * A simple default implementation. Takes O(n) with a large constant time.
 */
@Override
public BigFraction getCumulativeProbability(int x) {
	BigFraction sum = BigFraction.ZERO;
	x = Math.max(x, lowerBound()); // no need to add up a bunch of zeros
	for (; x < upperBound(); ++x) {
		sum = sum.add(getProbability(x));
	}
	return sum;
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:13,代码来源:AbstractDistribution.java

示例9: getCumulativeProbability

@Override
public BigFraction getCumulativeProbability(int x) {
	if (x < d.lowerBound()) {
		return BigFraction.ONE;
	} else if (x >= d.upperBound()) {
		return BigFraction.ZERO;
	} else {
		return cums[x - d.lowerBound()];
	}
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:10,代码来源:CachedCumulativeDistribution.java

示例10: distSumsToOne

/**
 * <p>
 * Called from other tests.
 */
public static void distSumsToOne(Distribution d) {
	BigFraction sum = BigFraction.ZERO;
	for (int i = d.lowerBound(); i < d.upperBound(); ++i) {
		sum = sum.add(d.getProbability(i));
	}
	assertEquals(BigFraction.ONE, sum);
	assertEquals(BigFraction.ONE,
			d.getCumulativeProbability(d.lowerBound()));
	assertEquals(BigFraction.ZERO,
			d.getCumulativeProbability(d.upperBound()));
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:15,代码来源:SlowTest.java

示例11: BigFractionMatrixConverter

/** Simple constructor. */
BigFractionMatrixConverter() {
    super(BigFraction.ZERO);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:4,代码来源:MatrixUtils.java

示例12: BigFractionMatrixConverter

/** Simple constructor. */
public BigFractionMatrixConverter() {
    super(BigFraction.ZERO);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:4,代码来源:MatrixUtils.java

示例13: getNumberOfVotes

public BigFraction getNumberOfVotes() {
    return (numberOfVotes != null) ? numberOfVotes : BigFraction.ZERO; // TODO: fühlt sich nach workaround an.
}
 
开发者ID:BGehrels,项目名称:singleTransferableVoteElections-web,代码行数:3,代码来源:VotesForCandidate.java

示例14: getProbability

@Override
public BigFraction getProbability(int x) {
	return x == this.x ? BigFraction.ONE : BigFraction.ZERO;
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:4,代码来源:ConstantDistribution.java

示例15: getCumulativeProbability

@Override
public BigFraction getCumulativeProbability(int x) {
	return x > this.x ? BigFraction.ZERO : BigFraction.ONE;
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:4,代码来源:ConstantDistribution.java


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