Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #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?

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 05:05 AM.

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