timcdlucas / RandEM

Random Encounter Modelling in R
4 stars 2 forks source link

Numeric instability at small numbers #4

Open timcdlucas opened 6 years ago

timcdlucas commented 6 years ago

Worth checking this more carefully at some point.

This one is ok (top right corner of Fig 4 in gREM paper, i.e. gas model).

count <- 2
v = 20
tm_days = 2
r_kilometers <- 1
theta <- 2 * pi
p <- r_kilometers*(theta + 2*sin(theta/2))/pi

D <- count / {v * tm_days * p}

p_exact <- r_kilometers*2

D2 <- count / {v * tm_days * p_exact}

Bottom right looks like it might behave weirdly.