lundi 2 janvier 2017

Random number with probability

I am trying to generate a random number and have a probability of x% to get closer of the max value.

Problem is that I have no idea how to do this, unless I make some steps?

Let's say I'll generate a random number between 1 and 3000.

$number = mt_rand(1, 3000)

This will return 2700 for example. I would like it to be closer to 1 than 3000.

How should I implement a function that will only have a 10% chance to get near 3000?




Aucun commentaire:

Enregistrer un commentaire