![]() |
|
#1
|
|||
|
|||
|
hi
im using ran2 as my RNG. im initializing my "seed" as any arbitrary negative value and then running a loop to get 10 random numbers. i did not change the value of "seed" after the initializing. my problem is that even though the book says the random numbers should be generated between 0.0 and 1.0 im getting the values to be of the order 10^9. Furthermore while these numbers are random they cease to be random after the 5th iteration of the loop and im getting a constant value of "-419434". Can anyone tell me whats going on?
|
|
#2
|
|||
|
|||
|
hi
Quote:
Quote:
Anyhow... How the heck could anyone guess "what's going on" without seeing your code? Here's the output I get from Version 2 C++: Code:
Seed = -123456 x = 5.147067e-01 x = 7.798369e-01 x = 2.298345e-01 x = 1.264292e-02 x = 7.142276e-01 x = 6.548146e-01 x = 7.834399e-01 x = 6.729629e-01 x = 4.629217e-01 x = 9.073786e-01 x = 4.164615e-01 x = 8.205473e-01 x = 3.420125e-01 x = 3.256488e-01 x = 1.143800e-02 x = 4.128037e-02 x = 7.887734e-01 x = 3.997021e-01 x = 6.184547e-01 x = 6.316700e-01 After 20 calls to ran2: (xmin,xmax) = (1.143800e-02, 9.073786e-01) Code:
Seed = -7654321 x = 1.215040e-01 . . (18 other values here) . x = 2.656290e-01 After 20 calls to ran2: (xmin,xmax) = (9.409017e-04, 9.837023e-01) Want to see my code? Well, I'll show you mine if you show me yours. Regards, Dave |
![]() |
| Thread Tools | |
| Display Modes | |
|
|