Random number generators discussion

Random number generators | www.agner.org

thread generate N-independent uniform random numbers? - windyfeng - 2005-12-26
last reply generate N-independent uniform random numbers? - Agner - 2005-12-28
generate N-independent uniform random numbers?
Author:  Date: 2005-12-26 05:27
Dear everyone:
I donot know how to generate N totally independent uniform random number in one field such as [0...2^n-1]? I used the RANROT-B algorithm to generate N pseudo uniform random numbers, and It seemed that these random numbers have some dependence between them, and their dependence decreases as their distance in the generated list increases.
Is there such a solution? or I'm wrong. Can you give me any suggestion?

Thank you!

generate N-independent uniform random numbers?
Author: Agner Date: 2005-12-28 10:48
They are independent, accoding to the stringent "DIEHARD" tests.

A uniform random number modulo 2^n can be generated easily by taking n bits out of the 32 random bits generated by BRandom():

#include <time.h>                      // define time()
#include "randomc.h"                   // define random number generator classes
#include "mersenne.cpp"                // random number generator source code

int main() {
   const int n = 10;
   const int n_bit_mask = (1 << n) - 1;
   int i, r;
   TRandomMersenne rng(time(0));
   for (i=0; i<100; i++) {
      r = rng.BRandom() & n_bit_mask;
      printf("%i\n", r);