jeudi 4 juin 2015

Seed based randomization perl

I have an array defined say @Array(1..31). Now I have a code where I randomly select a number for a certain number of times and store the results in another array. Example below :

$a1 = $Array[rand(@Array)];
push (@a2, $a1);

Now when I execute this script multiple times, I see that the new array contains very different patter everytime. But I do not want that, I want to generate a similar pattern everytime- where seed comes into picture.

Can someone please help me in how to incorporate seed to randomly select elements from array which can be predictable.?




Aucun commentaire:

Enregistrer un commentaire