RE: [Boost-Users] Re: help with mersenne_twister

It sounds like Boost.Random may be a good choice for this.
I am not familiar with the "Diehard" tests. But I see a couple of problems in your example code: you are not creating a binary file, and you are not generating random numbers.
ofstream file("MTRNG.bin", ios::binary);
"ios::binary" means open the output text file without \n -> \r\n conversions. It does not make insertions and extractions binary.
file << MT;
This means to save the current state of the random number generator in the text output file. To output the generated random numbers (instead of the random number generator state), use: file << MT(); To output the generated random numbers to a binary file, use: const mt19937::result_type x = MT(); file.write((const char *) &x, sizeof(x));
A last note: Boost.Random currently only provides one non-deterministic RNG, and it only works on Linux. -Steve

----- Original Message ----- From: scleary@jerviswebb.com To: Boost-Users@yahoogroups.com Sent: Monday, March 17, 2003 3:34 PM Subject: RE: [Boost-Users] Re: help with mersenne_twister
It sounds like Boost.Random may be a good choice for this.
I am not familiar with the "Diehard" tests. But I see a couple of problems in your example code: you are not creating a binary file, and you are not generating random numbers.
ofstream file("MTRNG.bin", ios::binary);
"ios::binary" means open the output text file without \n -> \r\n conversions. It does not make insertions and extractions binary.
file << MT;
This means to save the current state of the random number generator in the text output file. To output the generated random numbers (instead of the random number generator state), use: file << MT(); To output the generated random numbers to a binary file, use: const mt19937::result_type x = MT(); file.write((const char *) &x, sizeof(x));
A last note: Boost.Random currently only provides one non-deterministic RNG, and it only works on Linux. -Steve Hello Steve, Thanks for your suggestions and corrections, you made my day for sure! I am sort of embarrassed as I have a decent amount of experience with C++ but this was my first attempt at writing to a binary file, incorrectly apparently! ;-) If you do not mind, I would like to ask a few additional questions: I notice there is mt19937 for the mersenne twister, and mt11213b for the mersenne twister. What is the difference between the two? What other deterministic random number generators does boost offer, and can I use them in the same fashion as mt19937 as far as object instantiation? I have Linux in VMWare as well as a standalone Linux box so I should be able to utilize the non-deterministic generator. Do you have any suggestions that I might keep in mind before I begin? And lastly (don't want to wear out my welcome.. lol), do you think there would be any benefit to using the advanced RNG classes in my research? Thanks so much, I really appreciate this. Have a good one! Jon Agiato JonAgiato@nyc.rr.com [Non-text portions of this message have been removed]
participants (2)
-
Jon Agiato
-
scleary@jerviswebb.com