Skip to content

speed up generation of infections #416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
initialise vectors to zero
  • Loading branch information
sbfnk committed Jul 4, 2023
commit fefe19b4bada5c0abe228abcdcc816c9e4870953
10 changes: 5 additions & 5 deletions inst/stan/functions/infections.stan
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ vector generate_infections(vector oR, int uot, vector gt_rev_pmf,
int t = ot + uot;
vector[ot] R = oR;
real exp_adj_Rt;
vector[t] infections = rep_vector(1e-5, t);
vector[ot] cum_infections = rep_vector(0, ot);
vector[ot] infectiousness = rep_vector(1e-5, ot);
vector[t] infections = rep_vector(0, t);
vector[ot] cum_infections;
vector[ot] infectiousness;
// Initialise infections using daily growth
infections[1] = exp(initial_infections[1]);
if (uot > 1) {
Expand All @@ -44,13 +44,13 @@ vector generate_infections(vector oR, int uot, vector gt_rev_pmf,
}
// iteratively update infections
for (s in 1:ot) {
infectiousness[s] += update_infectiousness(infections, gt_rev_pmf, uot, s);
infectiousness[s] = update_infectiousness(infections, gt_rev_pmf, uot, s);
if (pop && s > nht) {
exp_adj_Rt = exp(-R[s] * infectiousness[s] / (pop - cum_infections[nht]));
exp_adj_Rt = exp_adj_Rt > 1 ? 1 : exp_adj_Rt;
infections[s + uot] = (pop - cum_infections[s]) * (1 - exp_adj_Rt);
}else{
infections[s + uot] += R[s] * infectiousness[s];
infections[s + uot] = R[s] * infectiousness[s];
}
if (pop && s < ot) {
cum_infections[s + 1] = cum_infections[s] + infections[s + uot];
Expand Down