I need to create a random number.
But the twist is that% of lower numbers should be greater than higher.
For instance.
rand> 1 to 100
13 ,
15 ,
12 ,
16 , 87,
15 ,
27 ,
12 ,
1 ,
12 , 98,
12 , 53,
12 ,
14 ....
Bold integers will be returned from the range 1-100.
Mathematics should be like this: rand = a number lower than max/2
Hope you guys can help.
Ps, How would a matrix get into this? im not superior in math :(
The answer to abs seems to be this.
$up = $down = 0;
while(true)
{
if(abs((rand()%150)-50) < 50)
{
$up++;
}else
{
$down++;
}
if( ($up + $down) == 500){ break;}
}
echo $up . '/' . $down;