bLahmann / MonteCarloParticleTracer

0 stars 0 forks source link

Rare OutOfRangeExceptions when sampling a Distribution #2

Closed bLahmann closed 7 years ago

bLahmann commented 7 years ago

Seems like the code crashes when Math.random() returns exactly 0.0.

We could fix this with a simple catch, but I think the splines should be well defined at x = 0.0. Need to understand what exactly causes this.

bLahmann commented 7 years ago

The minimum inverseCumulativeProbability isn't guaranteed to be = 0.0 in the current implementation. Similarly, the max value isn't guaranteed to be = 1.0 but this is more of a floating point rounding issue while the former is an implementation issue.

This has been bandaged fixed with a catch statement for now. May be worth forcing the user to provide a 0.0 probability node with any defined distribution to avoid this issue in a cleaner way.