EpiNow2 Stan Functions
Convolution Functions

Functions for convolving time series. More...

Collaboration diagram for Convolution Functions:

Functions

vector convolve_with_rev_pmf (vector x, vector y, int len)
 
vector convolve_to_report (vector infections, vector delay_rev_pmf, int seeding_time)
 

Description

Functions for convolving time series.

Functions from convolve.stan for implementing convolutions between infections and delay distributions.

Function Documentation

◆ convolve_to_report()

vector convolve_to_report ( vector infections,
vector delay_rev_pmf,
int seeding_time )

Convolve infections to reported cases.

This function convolves a vector of infections with a reversed delay distribution to produce a vector of reported cases.

Parameters
infectionsA vector of infection counts.
delay_rev_pmfA vector representing the reversed probability mass function of the delay distribution.
seeding_timeThe number of initial time steps to exclude from the output.
Returns
A vector of reported cases, starting from seeding_time + 1.
Example
convolve_to_report({10, 20, 30, 40, 50}, {0.2, 0.8}, 1) convolves the infections with the reversed delay {0.2, 0.8} and drops the first (seeding_time = 1) entry, returning {18, 28, 38, 48}.

Definition at line 54 of file convolve.stan.

References convolve_with_rev_pmf().

Here is the call graph for this function:

◆ convolve_with_rev_pmf()

vector convolve_with_rev_pmf ( vector x,
vector y,
int len )

convolution_functions Functions

This file contains functions for performing discrete convolutions, which are used throughout the model to combine time series with delay distributions. Convolve a vector with a reversed probability mass function.

This function performs a discrete convolution of two vectors, where the second vector is assumed to be an already reversed probability mass function. It is implemented in C++, with a hand-written gradient, in inst/include/epinow2/convolve_with_rev_pmf.hpp, which gives the maths.

Parameters
xThe input vector to be convolved.
yThe already reversed probability mass function vector.
lenThe desired length of the output vector.
Returns
A vector of length len containing the convolution result.
Exceptions
Iflen is longer than the full convolution (n + D - 1) or shorter than x.
Example
convolve_with_rev_pmf({1, 2, 3, 4}, {0.5, 0.5}, 5) convolves x with a reversed two-day uniform delay, returning {0.5, 1.5, 2.5, 3.5, 2.0}.

Referenced by convolve_to_report(), and get_delay_rev_pmf().

Here is the caller graph for this function: