26 int seeding_time,
int index){
27 int gt_length = num_elements(gt_rev_pmf);
31 int inf_start = max(1, (index + seeding_time - gt_length + 1));
33 int inf_end = (index + seeding_time);
36 int pmf_accessed = min(gt_length, index + seeding_time);
38 real new_inf = dot_product(
39 infections[inf_start:inf_end], tail(gt_rev_pmf, pmf_accessed)
64 array[] real initial_infections,
int pop,
int ht,
65 int obs_scale, real frac_obs,
int initial_as_scale) {
67 int ot = num_elements(R);
71 vector[t] infections = rep_vector(0, t);
72 vector[ot] cum_infections;
73 vector[ot] infectiousness;
74 real growth =
R_to_r(R[1], gt_rev_pmf, 1e-3);
76 if (initial_as_scale) {
77 infections[1] = exp(initial_infections[1] - growth * uot);
79 infections[1] = infections[1] / frac_obs;
82 infections[1] = exp(initial_infections[1]);
85 real exp_growth = exp(growth);
87 infections[s] = infections[s - 1] * exp_growth;
92 cum_infections[1] = sum(infections[1:uot]);
98 exp_adj_Rt = exp(-R[s] * infectiousness[s] / (pop - cum_infections[nht]));
99 exp_adj_Rt = exp_adj_Rt > 1 ? 1 : exp_adj_Rt;
100 infections[s + uot] = (pop - cum_infections[s]) * (1 - exp_adj_Rt);
102 infections[s + uot] = R[s] * infectiousness[s];
105 cum_infections[s + 1] = cum_infections[s] + infections[s + uot];
127 int t = num_elements(shifted_cases);
128 vector[t] infections = rep_vector(1e-5, t);
130 vector[t] exp_noise = exp(noise);
132 infections = infections + shifted_cases .* exp_noise;
133 }
else if (prior == 0) {
134 infections = infections + exp_noise;
135 }
else if (prior == 2) {
136 infections[1] = infections[1] + shifted_cases[1] * exp_noise[1];
138 infections[i] = infections[i - 1] * exp_noise[i];
142 infections = infections + shifted_cases;
vector generate_infections(vector R, int uot, vector gt_rev_pmf, array[] real initial_infections, int pop, int ht, int obs_scale, real frac_obs, int initial_as_scale)
Generate infections using a renewal equation approach.