diff --git a/src/main/java/ca/joeltherrien/randomforest/NumericCovariate.java b/src/main/java/ca/joeltherrien/randomforest/NumericCovariate.java index 5d1c8dc..b9be60a 100644 --- a/src/main/java/ca/joeltherrien/randomforest/NumericCovariate.java +++ b/src/main/java/ca/joeltherrien/randomforest/NumericCovariate.java @@ -17,18 +17,20 @@ public class NumericCovariate implements Covariate{ @Override public Collection generateSplitRules(List> data, int number) { + final Random random = ThreadLocalRandom.current(); + // for this implementation we need to shuffle the data final List> shuffledData; if(number > data.size()){ shuffledData = new ArrayList<>(data); - Collections.shuffle(shuffledData); + Collections.shuffle(shuffledData, random); } else{ // only need the top number entries shuffledData = new ArrayList<>(number); final Set indexesToUse = new HashSet<>(); while(indexesToUse.size() < number){ - final int index = ThreadLocalRandom.current().nextInt(data.size()); + final int index = random.nextInt(data.size()); if(indexesToUse.add(index)){ shuffledData.add(data.get(index));