Skip to content

Commit

Permalink
Fix a bug (variable q1 > 1, sometimes) #463
Browse files Browse the repository at this point in the history
  • Loading branch information
zjzxiaohei committed Oct 20, 2024
1 parent e9b2b82 commit b23dcc7
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public RandomVariable<Integer[]> sample() {
q1[i] = 0.0;
else {
q1[i] = this.p.value()[i] / cum_prob;
if (q1[i] > 1.0){q1[i] = 1.0;}
cum_prob = cum_prob - this.p.value()[i];
if (cum_prob < 0){ cum_prob = 0;}
}
}
q = new Value<>("q", q1);
Expand Down

0 comments on commit b23dcc7

Please sign in to comment.