I'm trying to output a number between 0 and N, where the input is a random number between 0 and MAX_SAFE_INTEGER.
For example:
Input(49 random numbers between 0 and MAX_SAFE_INTEGER). Output(49 random numbers between 0 - 48 (doesn't have to be one of each just an equal distribution), based off the MAX_SAFE_INTEGER).
I've tried using modular based on the index of each element of the array.
function getRandomArray(randomBigNums) {
return randomBigNums.map(function(number, index) {;
return number % (randomBigNums.length - index);
});
}
The premise being that each time I map a number it return give a number between 0 and 48, 0 and 47 etc to a equal distribution of all the numbers, but it seems to be more biased towards lower numbers.
Aucun commentaire:
Enregistrer un commentaire