Skip to content

Commit

Permalink
Add ParetoSampling computed weight assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
gstamatelat committed Aug 22, 2022
1 parent 96d674d commit 9b8a396
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/gr/james/sampling/ParetoSampling.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public boolean feed(T item, double weight) {

// Calculate item weight
final Weighted<T> newItem = new Weighted<>(item, (r * (1 - weight)) / ((1 - r) * weight));
assert newItem.weight >= 0.0; // weight can also be 0.0 because of double precision

// Add item to reservoir
if (pq.size() < sampleSize) {
Expand Down

0 comments on commit 9b8a396

Please sign in to comment.