This commit is contained in:
caoyixiong 2019-06-27 19:50:19 +08:00
parent 65a4d27e1e
commit 771263eef6

View File

@ -105,7 +105,7 @@ public class Chooser<K, T> {
double weight = item.weight();
//ignore item which weight is zero.see test_randomWithWeight_weight0 in ChooserTest
if (!(weight > 0)) {
if (weight <= 0) {
continue;
}
@ -124,7 +124,7 @@ public class Chooser<K, T> {
for (Pair<T> item : itemsWithWeight) {
double singleWeight = item.weight();
//ignore item which weight is zero.see test_randomWithWeight_weight0 in ChooserTest
if (!(singleWeight > 0)) {
if (singleWeight <= 0) {
continue;
}
exactWeights[index++] = singleWeight / originWeightSum;
@ -139,9 +139,9 @@ public class Chooser<K, T> {
double doublePrecisionDelta = 0.0001;
if (index == 0 || (Math.abs(weights[index - 1] - 1) < doublePrecisionDelta)) {
throw new IllegalStateException(
"Cumulative Weight caculate wrong , the sum of probabilities does not equals 1.");
return;
}
throw new IllegalStateException("Cumulative Weight caculate wrong , the sum of probabilities does not equals 1.");
}
@Override