Random number generators discussion

Random number generators | www.agner.org

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);
thread generate N-independent uniform random numbers? new - windyfeng - 2005-12-26
last reply generate N-independent uniform random numbers? - Agner - 2005-12-28