Subject: Random Numbers Using MersenneTwister
Posted By: JoeDW Post Date: 9/13/2006 11:10:15 AM
I have question regarding a solution I am trying to implement. My question is simply will it work. Basically I use the MesenneTwister algorithm to generate 2 pseudo-random numbers, they are then used in two instances of the Random class as the seed.


MersenneTwister randGen = new MersenneTwister();

mt_r1 = new Random(randGen.Next());

mt_r2 = new Random(randGen.Next());


I then call a function called Randomize that passes in a length of the new random number and a number set 0 - 9. The randomize function has an array that has a length of 12, a for loop fills the array indices using % 2 for even and odd numbers.


for (int i = 0; i < length; i++)
{
if (i % 2 == 0)
{
            ret[i] = characters[mt_r1.Next(characters.Length)];
}
else if (i % 2 == 1)
{
            ret[i] = characters[mt_r2.Next(characters.Length)];
}
}


Is this a viable solution? And does it actually aid in randomizing the already random number given from the MersenneTwister algorithm?


Go to topic 49689

Return to index page 176
Return to index page 175
Return to index page 174
Return to index page 173
Return to index page 172
Return to index page 171
Return to index page 170
Return to index page 169
Return to index page 168
Return to index page 167