Skip to content

Commit

Permalink
Adding setter method for AVLTreeDigest gen object
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-hansen committed Jan 4, 2022
1 parent 0541d15 commit 928372b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion core/src/main/java/com/tdunning/math/stats/AVLTreeDigest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import static com.tdunning.math.stats.IntAVLTree.NIL;

public class AVLTreeDigest extends AbstractTDigest {
final Random gen = new Random();
Random gen = new Random();
private final double compression;
private AVLGroupTree summary;

Expand All @@ -47,6 +47,17 @@ public AVLTreeDigest(double compression) {
summary = new AVLGroupTree(false);
}

/**
* Sets the random object for random number generation purposes.
* In cases where a reproducible tree should be created, this function may be used to make the
* randomness in this AVLTree become more deterministic.
*
* @param rand Random object to use for RNG purposes
*/
public void setRandom(Random rand) {
gen = rand;
}

@Override
public TDigest recordAllData() {
if (summary.size() != 0) {
Expand Down

0 comments on commit 928372b

Please sign in to comment.