stripe / rainier

Bayesian inference in Scala.
https://rainier.fit
Apache License 2.0
433 stars 51 forks source link

fix poisson for large values of lambda #390

Closed avi-stripe closed 5 years ago

avi-stripe commented 5 years ago

For lambda > 745, e^-lambda = 0.0 in the Double representation. This fix switches to a more numerically stable algorith, per https://en.wikipedia.org/wiki/Poisson_distribution#Generating_Poisson-distributed_random_variables

codecov-io commented 5 years ago

Codecov Report

Merging #390 into develop will increase coverage by 0.28%. The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #390      +/-   ##
===========================================
+ Coverage    47.08%   47.37%   +0.28%     
===========================================
  Files           88       88              
  Lines         3260     3272      +12     
  Branches       150      146       -4     
===========================================
+ Hits          1535     1550      +15     
+ Misses        1725     1722       -3
Impacted Files Coverage Δ
.../main/scala/com/stripe/rainier/core/Discrete.scala 85.54% <100%> (+1.75%) :arrow_up:
.../main/scala/com/stripe/rainier/core/SBCModel.scala 76.47% <100%> (+1.47%) :arrow_up:
...ain/scala/com/stripe/rainier/compute/RealOps.scala 79.66% <0%> (+2.54%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ed63d59...973b4ce. Read the comment docs.