![]() |
|
#1
|
|||
|
|||
|
ran2 problems (bug???)
I've copied the ran2 function from http://lib-www.lanl.gov/numerical/bookcpdf/c7-1.pdf
. I use time(NULL) as initial seed. For some reason first eight numbers are totally equal from one run to another. There are some more equal nubers in other places. I test the program with the following commands (on linux) $ ./ran2test > one; sleep 1; $ ./ran2test >two; $ paste one two | awk -F' ' '{print $1-$2}' | cat -n These commands generate two different sequences and then compare the corresponding elements. I've attached a text file that contains the ran2 function, the test program and some outputs. Can someone comment on this ? |
|
#2
|
|||
|
|||
|
It turns out bgbg forgot to initialize ran2 with a negative seed.
|
|
#3
|
|||
|
|||
|
OOOOOOOOOOOOOOOOPS
it was a classic RTFM mistake. Sorry.
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|