Random number generators discussion

Random number generators | www.agner.org

 
thread How is Mother-of-all compared to ran2? - Ngo Minh Toan - 2006-03-15
last replythread Warning message for mersenne.cpp - Ngo Minh Toan - 2006-03-15
last replythread How is Mother-of-all compared to ran2? - Agner - 2006-03-16
last replythread How is Mother-of-all compared to ran2? - Ngo Minh Toan - 2006-03-16
last reply How is Mother-of-all compared to ran2? - Agner - 2006-03-18
 
How is Mother-of-all compared to ran2?
Author:  Date: 2006-03-15 15:56
Dear Agner,

Sorry if my question has already been answered.
I would like to know how Mother-of-all is compared to ran2 by the Numerical Recipes team, in terms of 1) cycle length, 2) randomness and 3) speed (more important). It seems that you have better cycle?

I am doing simulation with Langevin dynamics and Monte Carlo. I've been using ran2 for all the time. In my simulation, I've optimized every possible piece of code and now it spends more than one half of simulation time just creating random numbers. Now I need something better than ran2 (speed and cycle length). It seems that your generator will satisfy me.

Thank you very much.

   
Warning message for mersenne.cpp
Author:  Date: 2006-03-15 17:45
Dear Agner,

First, I would like to inform you an "unofficial" fact of the time benchmarking:
I have compiled mersenne.cpp, Ranrotw.cpp, Mother.cpp and the versions in assembly of them versus ran2 in Linux Redhat 8.1, icc 7.1 compiler, intel xeon 2.8 GHz. The results on time consuming roughly are:


Function time
ran2 = 1
mersenne ~ 0.6
Ranrot ~ 0.7
Mother ~ 1.17
MT Assembly ~ 0.47
Ranrot Asse. ~ floating point exception (why?)
Mother Asse. ~ 0.69

So if the quality is more or less the same in any of them, I would choose the fastest one, which is MT in its assembly version.

Next, I one question concerning the compilation. I compiled MT in C++ version with the above compiler, it posted a warning as follows:

icc ex-ran.cpp
mersenne.cpp(61): warning #68: integer conversion resulted in a change of sign
const uint32 UPPER_MASK = -1L << MERS_R; // upper (32 - MERS_R) bits
^
So it is warning serious? Can I just ignore it or we have to fix it?

Thank you very much for any reply.

Best,
Toan.

   
How is Mother-of-all compared to ran2?
Author: Agner Date: 2006-03-16 07:53
Mother-of-all is better than ran2. Mersenne Twister is generally regarded as the best one.

If you have a speed problem then you may update your Intel compiler to the latest version (the noncommercial Linux version is free) and enable the SSE2 instruction set. The Gnu compiler is also very good.

The warning for mersenne.cpp is not serious. The sign change was intended. Does the warning disappear if you change -1L to 0xFFFFFFFF ?

You should not get a floating point exception in ranrot. Do you have the right function prototype from randoma.h ?

   
How is Mother-of-all compared to ran2?
Author:  Date: 2006-03-16 10:37
Mother-of-all is better than ran2. Mersenne Twister is generally regarded as the best one.
It is very good to know. I will choose MT for my simulations. I thought Mother-of-all, as its name would indicate, was the best one. Even though MT is rather new, I like it because it has a colossal period 10^6001 (compared to 10^18 by ran2) and with your code, it works more than twice faster than ran2! It has also been tested strictly. Do you have or can you give me a hint for any test which compares directly MT with ran2? I tried to google the matter, but only indirect materials did I find.

The warning for mersenne.cpp is not serious. The sign change was intended. Does the warning disappear if you change -1L to 0xFFFFFFFF ?

Yes, the warning disappeared when I made the change! Should I keep the code after change or I should convert it back to the -1L one? The two numbers should be the same?

You should not get a floating point exception in ranrot. Do you have the right function prototype from randoma.h ?

Yes, I did! But still. Maybe due to the fact that my OS is the 32-bit version?

Thank you very much for your answers and your effort to build and distribute the code!

   
How is Mother-of-all compared to ran2?
Author: Agner Date: 2006-03-18 07:07
I have changed the -1L to 0xFFFFFFFF now.
I will check up on the ranrot asm later.