The code is written in C++ for generating a random number as-
X = (((double) rand() / (RAND_MAX))-0.500000000000000);
Y = (((double) rand() / (RAND_MAX))-0.500000000000000);
Z = (((double) rand() / (RAND_MAX))-0.500000000000000);
mod = sqrt((X*X)+(Y*Y)+(Z*Z));
//cout<< mod << " " ;
x= X*rmax/mod;
y= Y*rmax/mod;
z= Z*rmax/mod;
This part of the script generates a unit direction vector for the next step of a random walk in an aggregation model. The precision obtained, despite that I used data type double is up to 6 or 7 decimal places only, eg. output)
X=-0.399531, Y=, 0.318677, Z=0.4281
X=-0.0994908, Y=, -0.317307, Z=0.30371
X=-0.174996, Y=, -0.034593, Z=-0.315512
X=-0.268187, Y=, -0.218015, Z=-0.147229
X=-0.282077, Y=, 0.0556219, Z=-0.177957
X=0.351115, Y=, -0.251124, Z=-0.191628
The program needs precision to atleast 10-12 decimal places.
The seed I used for RNG(random number generator) is "srand(time(NULL));" the program needs to generate 50,000 to 100,000 steps for every particle, and henceforth the random numbers generated have to be non-periodic and non-repetitive in behavior over this range.
Please suggest me a way to get more precision after the decimals.
Aucun commentaire:
Enregistrer un commentaire