My mathematical knowledge might be limited to solve this myself. I've found a similar question, however, with focus on center and not borders.
I would like to create random numbers with max and min but with focus on the max and min, so numbers closer to max and min's should appear more frequent than the ones in between.
I remember that in mathematics there is a function to create a parabola curve:
And using this online tool i kind of generated the function I am looking for, which should be like
y = 0.05 * x^2
This is my basic idea and trying to turn it into javascript i ended up with this:
for (let i = 0; i < 100; i++) {
// Create random x with ^ 2 with max=100 and min=0
let x = Math.pow(Math.floor(Math.random() * (100 - 0 + 1)) + 0, 2);
// log the random number in the console
console.log(0.05 * x);
}
But of course this doesn't make any real sense as I also can see in the console (I ordered them so it's more clear to see)
> 0 0
> 0.05
> 0.05
> 0.2
> 0.2
> 0.8
> 2.45
> 3.2
> 3.2
> 3.2
> 4.05
> 4.05
> 4.05
> 6.05
> 8.45
> 8.45
> 14.45
> 16.2
> 16.2
> 16.2 20 20
> 22.05
> 22.05
> 22.05
> 26.45
> 28.8
> 28.8
> 31.25
> 33.8
> 36.45
> 39.2
> 42.05
> 48.05
> 48.05
> 48.05
> 51.2
> 57.8
> 57.8
> 57.8
> 64.8
> 64.8
> 64.8
> 68.45
> 76.05
> 88.2
> 88.2
> 92.45
> 92.45
> 92.45
> 96.8
> 101.25
> 105.8
> 110.45 125
> 130.05
> 130.05
> 135.2
> 140.45
> 140.45
> 145.8
> 145.8
> 145.8
> 156.8
> 162.45
> 162.45
> 162.45 180 180
> 198.45
> 204.8
> 204.8
> 224.45
> 231.2
> 231.2
> 231.2
> 231.2
> 238.05
> 238.05
> 259.2 320 320
> 328.05
> 344.45
> 352.8
> 352.8
> 361.25
> 369.8
> 387.2
> 387.2
> 423.2
> 423.2
> 432.45
> 451.25
> 460.8
> 470.45
> 470.45
> 490.05
> 490.05
Anybody who maybe has an idea?
Aucun commentaire:
Enregistrer un commentaire