Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 13th, 2006, 11:10 AM
Registered User
Join Date: Sep 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to JoeDW
Default Random Numbers Using MersenneTwister

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?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating random numbers invisibleman18 Java Basics 2 March 26th, 2007 12:22 AM
Random Numbers welshboy2005 C# 1 May 19th, 2005 06:01 AM
Append random numbers to link XXL Classic ASP Basics 3 March 8th, 2005 04:43 AM
random numbers from/to database HammR PHP Databases 10 January 14th, 2005 12:08 PM
Random Numbers not so random... katsarosj ASP.NET 1.0 and 1.1 Basics 5 November 20th, 2003 12:55 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.