MesserLab / SLiM

SLiM is a genetically explicit forward simulation software package for population genetics and evolutionary biology. It is highly flexible, with a built-in scripting language, and has a cross-platform graphical modeling environment called SLiMgui.
https://messerlab.org/slim/
GNU General Public License v3.0
160 stars 33 forks source link

allow out-of-bounds points from `pointDeviated`, optionally? #398

Closed petrelharp closed 1 year ago

petrelharp commented 1 year ago

As discussed in #395, I'll bet people will want to be able to return out-of-bounds points from pointDeviated, to model e.g. seeds that get thrown outside the area. (So, use case is to generate migrants and then discard those who are out of bounds.)

On the one hand, it'd be straightforward in the code to allow for this (just don't do the rejection sampling); but on the other hand, this is already easy to do by just drawing the displacements yourself. So maybe we should either (a) add this option (named inBounds, perhaps), or (b) make a note in the documentation saying that if you want poitns that can be out of bounds, just add the displacements yourself.

bhaller commented 1 year ago

I think this is already supported? Just pass "none" as the boundary condition for pointDeviated() and it should allow points to be wherever? Or is there a problem with that?

jiseonmin commented 1 year ago

So if I wanted to use absorbing boundary condition, should I use "none" for pointDeviated and then use pointInBounds on the returned vector? I guess that works, but it could be a duplicated work if pointDeviated checks for boundaries already?

bhaller commented 1 year ago

In the general case of drawing from different kernels, yes. In the specific case of drawing deviations from a Gaussian kernel, I'd probably just do it the old way – use rnorm() to draw the deviations, and + to add then in, and pointInBounds() to decide the fate of the offspring. Either way really.

bhaller commented 1 year ago

Resolved? Seems like? Closing.

petrelharp commented 1 year ago

Hah, excellent. Thanks!