vendredi 19 mai 2023

Calling random number generator ran2() available in Numerical recipes in c

I am using ran2() function in c programming codes. ran2() is known as more truly random number generator. I found that ran2() is also generates numbers in same sequence. Why is it so?

ran2 takes a long type pointer variable.

The code of ran2() is available in Numerical recipes.

Here I'm writing how I called the function:

float temp;
long *seed,seed1;
seed=&seed1;
temp=ran2(seed);

After calling this function multiple times and running multiple times I see that numbers of same sequence are generated every time. Correct me where I am doing the mistake and what modifications needed to get the truly random sequence every time.




Aucun commentaire:

Enregistrer un commentaire