# Thread: Independent streams of pseudo random number generator

1. ## Independent streams of pseudo random number generator

Hi,
Could somebody please explain how to generate two independent streams of random numbers using erand48()?
My original theory was to just use 2 different shorts as inputs, ie

double rand1, rand2;
unsigned short s1[3], s2[3];

rand1 = erand48(s1);
rand2 = erand48(s2);

However this just prduced 2 *identical* streams.

One solution that was presented to me was use erand48 as above for the first stream. Then for the second, use numbers far enough down the stream so that the random value has no dependance on the initial seed, by running the erand48 something like 1,000,000 times. However, when trying to save these variables I get error messages that say that an array cannot be that large (1,000,000).
Is there another way to store these variables? Am I even on the right track?

Any help is appreciated.

2. Hi!

You can make your random generator better if you do this:
Code:
```#define MAX 100
long rand;
rand1 = erand48(s1);
rand2 = erand48(s2);
rand=rand1*rand2%(MAX+1)```
but it won´t be really independent, too.

klausi