EpiNow2 Stan Functions
pmfs.stan
Go to the documentation of this file.
1/**
2 * Probability Mass Function (PMF) Utilities
3 *
4 * This file contains functions for creating and manipulating probability mass
5 * functions, particularly for discretizing continuous distributions for use in
6 * delay modeling.
7 *
8 * @ingroup pmf_handlers
9 */
10
11/**
12 * Discretise a continuous distribution using primary censoring
13 *
14 * Computes a properly primary-censored PMF using the vendored
15 * primarycensored Stan functions. Assumes uniform primary event
16 * distribution within a window of width 1.
17 *
18 * @param params Distribution parameters as a vector
19 * @param n Number of days to calculate PMF for (max_delay + 1)
20 * @param dist Distribution type using primarycensored convention
21 * (1: lognormal, 2: gamma, 3: weibull, 4: exponential)
22 * @param L Left truncation point (0 for no truncation)
23 * @return A vector of length n containing the discretised PMF
24 *
25 * @par Example
26 * `discretised_pmf({5, 2}, 6, 2, 0)` discretises a Gamma(shape = 5,
27 * rate = 2) distribution over 6 days (0 to 5), returning the probability
28 * mass on each day, e.g. `{0.011, 0.186, 0.366, 0.271, 0.123, 0.043}`.
29 *
30 * @ingroup pmf_handlers
31 */
33 vector params, data int n, int dist, data int L
34) {
35 array[0] real primary_params;
37 n - 1, L * 1.0, n * 1.0, dist,
38 to_array_1d(params), 1.0, 1, primary_params
39 );
40}
vector discretised_pmf(vector params, data int n, int dist, data int L)
Definition pmfs.stan:32
vector primarycensored_sone_pmf_vectorized(data int max_delay, data real L, data real D, data int dist_id, array[] real params, data real pwindow, data int primary_id, array[] real primary_params)