I want to obtain a random valu
I want to obtain a random value at each 'imode' loop:
for(int imode=1;imode<=10;imode++) { Random pertA(1234567); ampA=pertA.GaussNormal(); Info<<"ampA:"<<ampA<<endl; } But, it is strange that I got the same value for all 'imode' loop! Why? By the way, some of the random values will be great than unit? Is something wrong? 
Move
Random pertA(1234567)
Move
Random pertA(1234567); to before the loop. 
Thank you, Henry. The result i
Thank you, Henry. The result is nice. But some of the random values are big than 1 or less than 1. Why?
I cannot find the implementation file Random.C of the class Random. In the subdirectory 'src/OpenFOAM/primitives/random/', I found a file called Random.C which is not the right one. I use OpenFOAM1.1. 
Random.C is the right one, Gau
Random.C is the right one, GaussNormal() is the last function in that file:
// return a normal Gaussian randon number // with zero mean and unity variance N(0, 1) scalar Random::GaussNormal() { static int iset = 0; static scalar gset; scalar fac, rsq, v1, v2; if (iset == 0) { do { v1 = 2.0*scalar01()  1.0; v2 = 2.0*scalar01()  1.0; rsq = v1*v1 + v2*v2; } while (rsq >= 1.0  rsq == 0.0); fac = sqrt(2.0 * log(rsq)/rsq); gset = v1*fac; iset = 1; return v2*fac; } else { iset = 0; return gset; } } I am not sure if this method is required to limit the values between 1 and 1. If it is an issue for you I suggest you clip the values although this will probably distort the Gaussian distribution slightly. 
That file is random.c not Rand
That file is random.c not Random.C, do you have a caseinsensitive filing system?

Sorry, I have found the right
Sorry, I have found the right Random.C file in my cluster machines where I have installed the full package. Maybe when I transfer the source files from the cluster machines to my local PC, the file random.C overrided Random.C.
Sorry for time wasting. 
Dear Zou Mo
Gauss distributio
Dear Zou Mo
Gauss distribution with mean 0 and variance 1 , can give values less than 1 or higer than 1. 
Hello everybody
I want to o
Hello everybody
I want to obtain n random values for use at each runtime , by using OF Randomclass. But prooduced random values are similar in all runtime. Is something wrong? Regards Marhamat 
In Random points(1234567) wh
In Random points(1234567) what does mean (1234567)?And what does happen when i change 7 to 8? Why?
Thanks alot Marhamat 
I guess it is the seed of the
I guess it is the seed of the (pseudo)random sequence of numbers that is produced by the randomnumbergenerator. By changing it you get a different sequence. But by fixing the seed you make sure that every simulation runs with the same sequence thus making the results reproducible.

Thanks alot Bernhard
I want t
Thanks alot Bernhard
I want to use different sequence in different time steps;So i think i must change the number or arrangement of digits in Random points(1234567). After testing some case,for example: Random points(1234567); Random points(1234568); Random points(1434568); Random points(1111); Random points(3); I get different sequance. But i don't know the governing rules that change random sequence of numbers by changing the number or arrangement of digits. Q1)What Does mean the number or arrangement of these digits? Q2)How do i controll randomnumbergenerator for producing different sequence in different time steps? Is any references available in this field? Please explan me more details. With kind regards Marhamat 
A random number generator gene
A random number generator generates a "pseudo"random number from the previous number. The number you give to the constructor is the start of the sequence (the predescessor of your first random number)
Have a look at http://en.wikipedia.org/wiki/Random_number_generator or "The Art of computer programming" Volume 2 by Donald E. Knuth (http://en.wikipedia.org/wiki/The_Art...er_Programming) if you REALLY want to know it in detail 
I have a problem with this Random class, I pass the seed 0 which should make random numbers on each run but the numbers are getting repeated!!! How should I force it to generate different numbers at each run time?

Quote:
Just use different seeds if you want different results. The advantage of the behaviour you describe is that results are reproducible. Which is a good thing 
Guess I read it somewhere that I can't remember it. By looking at Random.C I understand you are right, but what should I do if I want to have different seeds at every run automatically? I want to make a statistical study and changing the seed manually does not look so helpful.

Quote:
OR you read the seed from a dictionary. That dictionary is manipulated with a script that changes the seed ... using a pseudorandom value ... that has a fixed seed. That way you have a statistical study ... that is reproducible 
All times are GMT 4. The time now is 15:48. 