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)
66 array[] real initial_infections, real pop,
67 int use_pop, real pop_floor,
int ht,
int obs_scale, real frac_obs,
68 int initial_as_scale) {
70 int ot = num_elements(R);
74 vector[t] infections = rep_vector(0, t);
75 vector[ot] cum_infections;
76 vector[ot] infectiousness;
77 real growth =
R_to_r(R[1], gt_rev_pmf, 1e-3);
79 if (initial_as_scale) {
80 infections[1] = exp(initial_infections[1] - growth * uot);
82 infections[1] = infections[1] / frac_obs;
85 infections[1] = exp(initial_infections[1]);
88 real exp_growth = exp(growth);
90 infections[s] = infections[s - 1] * exp_growth;
95 cum_infections[1] = sum(infections[1:uot]);
100 if ((use_pop == 1 && s > nht) || use_pop == 2) {
101 real susceptible = fmax(pop_floor, pop - cum_infections[s]);
102 exp_adj_Rt = exp(-R[s] * infectiousness[s] / susceptible);
103 infections[s + uot] = susceptible * fmax(0, 1 - exp_adj_Rt);
105 infections[s + uot] = R[s] * infectiousness[s];
107 if (use_pop && s < ot) {
108 cum_infections[s + 1] = cum_infections[s] + infections[s + uot];
130 int t = num_elements(shifted_cases);
131 vector[t] infections = rep_vector(1e-5, t);
133 vector[t] exp_noise = exp(noise);
135 infections = infections + shifted_cases .* exp_noise;
136 }
else if (prior == 0) {
137 infections = infections + exp_noise;
138 }
else if (prior == 2) {
139 infections[1] = infections[1] + shifted_cases[1] * exp_noise[1];
141 infections[i] = infections[i - 1] * exp_noise[i];
145 infections = infections + shifted_cases;
vector generate_infections(vector R, int uot, vector gt_rev_pmf, array[] real initial_infections, real pop, int use_pop, real pop_floor, int ht, int obs_scale, real frac_obs, int initial_as_scale)
Generate infections using a renewal equation approach.