Turns the cumulative distribution function (CDF) of a continuous distribution on positive values, such as a gamma distribution for the generation time, into the probability mass function on whole days used by the gen argument of epiinf and the i2o argument of epiobs. Its \(k\)th element is the probability of a delay in \((k-1, k]\) days. The distribution is truncated at n days and normalized to sum to one.

discretize_cdf(cdf, n, ...)

Arguments

cdf

A cumulative distribution function whose first argument is the quantile, such as pgamma.

n

The number of days of support.

...

Further arguments passed to cdf, such as the parameters of the distribution.

Value

A numeric vector of length n that sums to one.

Examples

# gamma distributed generation time with mean 5 days and standard deviation 3 days
gen <- discretize_cdf(pgamma, 30, shape = (5 / 3)^2, rate = 5 / 3^2)
inf <- epiinf(gen = gen)