From a2f47d65c16264475ee0ce646a5961059b4dd620 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 31 Jan 2024 21:33:47 +0000 Subject: [PATCH] Modified `RandomDataGenerator.weightedPick` method to avoid sampling past the last element. Fix #6701 --- src/math/random-data-generator/RandomDataGenerator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/math/random-data-generator/RandomDataGenerator.js b/src/math/random-data-generator/RandomDataGenerator.js index ac3775dc6..b2637cb39 100644 --- a/src/math/random-data-generator/RandomDataGenerator.js +++ b/src/math/random-data-generator/RandomDataGenerator.js @@ -390,7 +390,7 @@ var RandomDataGenerator = new Class({ */ 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)]; }, /**