Skip to content

Commit

Permalink
Replace rand with newer versions random_int
Browse files Browse the repository at this point in the history
  • Loading branch information
akondas committed Dec 12, 2016
1 parent 2363bba commit 4dc8271
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Phpml/Clustering/KMeans/Space.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function getRandomPoint(Point $min, Point $max)
$point = $this->newPoint(array_fill(0, $this->dimension, null));

for ($n = 0; $n < $this->dimension; ++$n) {
$point[$n] = rand($min[$n], $max[$n]);
$point[$n] = random_int($min[$n], $max[$n]);
}

return $point;
Expand Down Expand Up @@ -243,7 +243,7 @@ protected function initializeKMPPClusters(int $clustersNumber)
$sum += $distances[$point] = $distance;
}

$sum = rand(0, (int) $sum);
$sum = random_int(0, (int) $sum);
foreach ($this as $point) {
if (($sum -= $distances[$point]) > 0) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Phpml/NeuralNetwork/Node/Neuron/Synapse.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(Node $node, float $weight = null)
*/
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);
}

/**
Expand Down

0 comments on commit 4dc8271

Please sign in to comment.