Modified RandomDataGenerator.weightedPick method to avoid sampling past the last element. Fix #6701

This commit is contained in:
Richard Davey 2024-01-31 21:33:47 +00:00
parent 7c5e4dc2f6
commit a2f47d65c1

View file

@ -390,7 +390,7 @@ var RandomDataGenerator = new Class({
*/ */
weightedPick: function (array) weightedPick: function (array)
{ {
return array[~~(Math.pow(this.frac(), 2) * array.length + 0.5)]; return array[~~(Math.pow(this.frac(), 2) * (array.length - 0.5) + 0.5)];
}, },
/** /**