Skip to content

Commit

Permalink
Make rbinom prob 1 if susc is Inf
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmbaazam committed Jan 23, 2024
1 parent 34e02f4 commit c85e6d0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion R/simulate.r
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,17 @@ simulate_chains <- function(index_cases,
stop("Offspring distribution must return integers")
}
# Sample susceptible offspring to be infected from all possible offspring
# We first adjust for the case where susceptible can be Inf but prob is max
# 1.
binom_prob <- ifelse(
is.infinite(susc_pop),
1,
susc_pop / pop
)
next_gen <- stats::rbinom(
n = length(next_gen),
size = next_gen,
prob = susc_pop / pop
prob = binom_prob
)
# Adjust next_gen if the number of offspring is greater than the
# susceptible population.
Expand Down

0 comments on commit c85e6d0

Please sign in to comment.