Basically I want to generate a Random number but increase the chances of lower numbers appearing more.
if I just use mt_rand(1, 1000) the chances of getting the number 1 is the same as 468 which is the same as 1000.
I want to increase the chances of lower numbers appearing.
This poor way shows what I mean
So the chance of the number between 1 and 10 is higher than between 10 and 100 which is higher than 100 and 1000.
It's still pretty crap though as the chance of getting 124 is the same as 975 (not to mention it's generating upto 5 times to get one result).
I want a gradual increase in chance. I don't even know the mathematical term. Searching "php random sliding scale" gives random image scripts and "php random heavy slide" gives articles on the difference between rand() and mt_rand()
Can anyone help with an fast efficient function or even tell me the mathematical term for what I want to make searching easier?
if I just use mt_rand(1, 1000) the chances of getting the number 1 is the same as 468 which is the same as 1000.
I want to increase the chances of lower numbers appearing.
This poor way shows what I mean
PHP:
if (mt_rand(1, 2) == 1) // 50-50 chance
{
mt_rand(1, 10);
}
else if (mt_rand(1, 2) == 1)
{
mt_rand(10, 100);
}
else
{
mt_rand(100, 1000);
}
So the chance of the number between 1 and 10 is higher than between 10 and 100 which is higher than 100 and 1000.
It's still pretty crap though as the chance of getting 124 is the same as 975 (not to mention it's generating upto 5 times to get one result).
I want a gradual increase in chance. I don't even know the mathematical term. Searching "php random sliding scale" gives random image scripts and "php random heavy slide" gives articles on the difference between rand() and mt_rand()
Can anyone help with an fast efficient function or even tell me the mathematical term for what I want to make searching easier?