How to generate several random numbers included in a range and whose evolution is in a range in percent?
The goal is to generate random numbers while avoiding significant discrepancies.
i tried this code but i ended up getting 0
$min=400; // starting value
$max = 600; // starting value
for ($i = 1; $i <= 1000; $i++)
{
$nb = random_int($min, $max);
echo $nb . "\n";
$percentage_min = random_int(0, 10);
$percentage_max = random_int(10, 20);
$min = $nb-($nb * $percentage)/100;
$max = $nb+($nb * $percentage_max)/100;
}
Aucun commentaire:
Enregistrer un commentaire