-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support user-supplied random number seed #1
Comments
Implemented for speciation-extinction. Soon to be for trait model as well. |
Hmm. running longer tests, runs diverge after a few thousand generations. Not sure what is going on... |
BTW I pulled and compiled but had no issues - the random seed worked fine (tested it up to 10^6 gens). I assume you have implemented yet for traits but worked fine in speciationextinction. On Nov 17, 2013, at 11:57 AM, Joseph W. Brown wrote:
|
Implemented for both now, but both diverge for me. Here are some results for the whale tree with seed = 12345 and printFreq = 1000. Run 1: Run 2: Diverges at random generations (i.e. not consistent across replicate runs). Maybe another OS-specific issue? |
I just tried your seed & example, worked fine. did you make clean before rebuilding (i assume you did, but weirdly, i got seg faults after pulling your last commit until I cleaned everything out again! make clean fixed it). On Nov 17, 2013, at 12:59 PM, Joseph W. Brown wrote:
|
Yeah, I always clean and rebuild it all to avoid those weird behaviours. Problem persists... I will try this on my wife's machine (different OS). |
Can you test if has something to do with BAMM versus the RNG or MbRandom class itself, like have dummy function in main that just calls the RNG a few million times to see if still diverges with no calls to BAMM associated functions? On Nov 17, 2013, at 1:09 PM, Joseph W. Brown wrote:
|
Yeah, I'll do that to localize the issue. BTW, it works correctly on my wife's 10.8.5 machine. |
So, uniformRv() runs consistently (tested up to 10MIL), and is the same across OSs. The diverging of BAMM results seems to happen (for me) after a few tens of thousand generations; i.e. not right away. Are there proposals/operations that occur very infrequently? |
ok, this is weird. I wonder how we might be able to profile this. I have to wonder if this could be some weird numerical thing. For example, maybe I have an inconsistent calculation (or improperly initialized variable) or something that is fine on my compiler, but for you it leads to very slight changes in the likelihoods (some address overhang or something in dynamic memory) that ultimately cause things to diverge. Maybe try setting sampleFromPriorOnly = 1 and run for a million gens. This may help localize things. I could see this being a headache to diagnose, especially if I can't replicate on my machine. On Nov 17, 2013, at 2:16 PM, Joseph W. Brown wrote:
|
Well, this seems to have been 'solved' on non-10.9 macs. I will therefore close it now. I am tempted to open a new issue "why things break on 10.9", but will resist for the time being. This, of course, should not be taken lightly; I imagine a lot of people (the majority?) have upgraded, or will soon do so, to 10.9, so this problem will not go away. |
Carlos - if you have 10.9 on one of your machines, maybe you can try some debugging on this if we can replicate it. I am definitely concerned with the RNG performance and it makes me wonder what could possibly be going on. On Nov 17, 2013, at 9:46 PM, Joseph W. Brown wrote:
|
One worry I have is the reference of "two" random number seeds (from MbRandom.cpp), emphasized as 'TWO' below: /* /* /* I am not sure where the '2nd' seed comes from, or how to manually supply it myself. |
weird - but shouldn't this have come up in your tests of the RNG outside of the bamm code? On Nov 17, 2013, at 10:06 PM, Joseph W. Brown wrote:
|
Even though the documentation of the MbRandom code mentions two seeds, I have yet to find a way to supply more than a single seed. |
It looks like you supply the two seeds in a single long int, using bitshifting to place them. Bitshifting allows you to move bits around a memory location, so they probably assign the seed the first number, then shift those bits to the left (filling the empty spaces with 0), and then adding the second number. Now the single long int contains "two" seeds. |
Is this where things are diverging for me? Should we implement an alternative way to set the second seed? |
I admit i'm confused by the documentation and am not sure its correct for that class. Here's the core RNG algorithm in the MbRandom class: (most of the random numbers are based on simple transformations of the uniform RNG below). I see nothing about bit shifting or 2 seeds! This looks like a pretty simple generator. /*!
|
OK, that code post looks terrible. in any event go look at MbRandom::uniformRV(void) |
Joseph, Carlos - one thing to try would be to make a dummy/experimental function for uniformRV in MbRandom that uses another uniformRV generator (maybe one from std). This would be a trivial change and would be good to know if it fixes the behavior joseph is observing. If it doesn't, that suggests that it is a problem with something else. The fact that the runs diverge does not mean, necessarily, that it is the fault of the RNG. If there is some weird numerical behavior going on because of (say) something not properly initialized, then the runs could diverge even if the same sequence of random numbers is called. On Nov 18, 2013, at 10:33 AM, Joseph W. Brown wrote:
|
Yeah, I confirmed that uniformRV runs identically across OSs, so that is not it. |
OK, this is a major issue (in my opinion). We may actually have to figure out the exact function call that causes these to diverge. This could be a pain. On Nov 18, 2013, at 10:48 AM, Joseph W. Brown wrote:
|
Agreed. I am starting a new issue (since the code itself is complete). Dan -- can you get Pascal to try running some replicate analyses with a constant seed value? He is the only other I know that is using 10.9. Just want to make sure that this is not just my problem alone. |
I ran bamm for 2,000,000 generations and didn't observe any divergence. I'm using OS X 10.7.5. |
For replication purposes. Default to clock (if provided seed == -1), otherwise use user-provided seed.
The text was updated successfully, but these errors were encountered: