mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-25 14:27:34 +00:00
Replace rand with newer versions random_int
This commit is contained in:
parent
2363bbaa75
commit
4dc82710c8
@ -118,7 +118,7 @@ class Space extends SplObjectStorage
|
|||||||
$point = $this->newPoint(array_fill(0, $this->dimension, null));
|
$point = $this->newPoint(array_fill(0, $this->dimension, null));
|
||||||
|
|
||||||
for ($n = 0; $n < $this->dimension; ++$n) {
|
for ($n = 0; $n < $this->dimension; ++$n) {
|
||||||
$point[$n] = rand($min[$n], $max[$n]);
|
$point[$n] = random_int($min[$n], $max[$n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $point;
|
return $point;
|
||||||
@ -243,7 +243,7 @@ class Space extends SplObjectStorage
|
|||||||
$sum += $distances[$point] = $distance;
|
$sum += $distances[$point] = $distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sum = rand(0, (int) $sum);
|
$sum = random_int(0, (int) $sum);
|
||||||
foreach ($this as $point) {
|
foreach ($this as $point) {
|
||||||
if (($sum -= $distances[$point]) > 0) {
|
if (($sum -= $distances[$point]) > 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -33,7 +33,7 @@ class Synapse
|
|||||||
*/
|
*/
|
||||||
protected function generateRandomWeight(): float
|
protected function generateRandomWeight(): float
|
||||||
{
|
{
|
||||||
return 1 / rand(5, 25) * (rand(0, 1) ? -1 : 1);
|
return 1 / random_int(5, 25) * (random_int(0, 1) ? -1 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user