Boost logo

Boost Users :

From: Jon Agiato (JonAgiato_at_[hidden])
Date: 2003-03-17 16:10:07


  ----- Original Message -----
  From: scleary_at_[hidden]
  To: Boost-Users_at_[hidden]
  Sent: Monday, March 17, 2003 3:34 PM
  Subject: RE: [Boost-Users] Re: help with mersenne_twister

> Hello Steve, and thank you for your kind help. I am trying to use
> the boost library as part of a project in which I demonstrate the
> validity of various random number generation algorithms and
> methodologies. I wanted to use boost to demonstrate what can be
> achieved through top class C++ generic programming.

  It sounds like Boost.Random may be a good choice for this.

> I used mt19937 as you directed and my example did compile but when I
> ran the binary file through Diehard it failed every single test
> every time. I am sure this can not be due to the algorithm, but I
> can not pinpoint what I could be doing in error. Here is the code I
> used to create a binary file for diehard:

  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));

> I was intending on using boost::random to demonstrate various
> deterministic and non-deterministic RNGs and their validity as far
> as randomness using Diehard.

  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_at_[hidden]

[Non-text portions of this message have been removed]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net