本文整理汇总了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;
}
}
示例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;
}
}
示例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);
}
}
示例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];
}
}
示例6: getProbability
@Override
public BigFraction getProbability(int x) {
if ((x >= 1 && x < sides) || x == sides + bonus) {
return probability;
} else {
return BigFraction.ZERO;
}
}
示例7: getProbability
@Override
public BigFraction getProbability(int x) {
if (x < lowerBound() || x >= upperBound()) {
return BigFraction.ZERO;
} else {
return getProbabilityBounded(x);
}
}
示例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;
}
示例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()];
}
}
示例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()));
}
示例11: BigFractionMatrixConverter
/** Simple constructor. */
BigFractionMatrixConverter() {
super(BigFraction.ZERO);
}
示例12: BigFractionMatrixConverter
/** Simple constructor. */
public BigFractionMatrixConverter() {
super(BigFraction.ZERO);
}
示例13: getNumberOfVotes
public BigFraction getNumberOfVotes() {
return (numberOfVotes != null) ? numberOfVotes : BigFraction.ZERO; // TODO: fühlt sich nach workaround an.
}
示例14: getProbability
@Override
public BigFraction getProbability(int x) {
return x == this.x ? BigFraction.ONE : BigFraction.ZERO;
}
示例15: getCumulativeProbability
@Override
public BigFraction getCumulativeProbability(int x) {
return x > this.x ? BigFraction.ZERO : BigFraction.ONE;
}