Skip to content

Commit

Permalink
Merge pull request #1552 from BlenderItUp/fix-random-number-bias
Browse files Browse the repository at this point in the history
Fixed Bias in ReturnNRandomRecords When Selecting Random Records
  • Loading branch information
alexed1 authored Jul 5, 2024
2 parents 9bc4823 + 7c9076d commit d3fd8fd
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ global inherited sharing class ReturnNRandomRecords {
} else {
// Generate a list of random numbers
while (randomNumbers.size() < recordCount) {
Integer randomNumber = (Integer)Math.round(Math.random() * (inputCollection.size()-1));
Integer randomNumber = (Integer)Math.floor(Math.random() * (inputCollection.size()));
if( !randomNumbers.contains(randomNumber) ) {
randomNumbers.add(randomNumber);
}
Expand Down

0 comments on commit d3fd8fd

Please sign in to comment.