Expectation Programming
Abstract
Building on ideas from probabilistic programming, we introduce the concept of an expectation programming framework (EPF) that automates the calculation of expectations.
Analogous to a probabilistic program, an expectation program is comprised of a mix of probabilistic constructs and deterministic calculations, between which a conditional distribution over internal variables and outputs is deﬁned.
However, the focus of the inference engine in an EPF is to directly calculate the expectation of the program return values, rather than this conditional distribution.
This is made possible by exploiting recent advancements in target–aware Bayesian inference, through which we can tailor our inference engines to this expectation estimation, providing the potential for substantial improvements over the standard probabilistic programming pipeline.
We realize a particular instantiation of our EPF concept by extending the probabilistic programming language Turing with a new @expectation macro that uses a series of program transformations to automatically run target–aware inference.
We show that this leads to signiﬁcant empirical gains in estimation performance compared to conventional use of Turing on two example problems.
1. Introduction
Calculating expectations is at the center of many scientiﬁc workﬂows.
For example, the decision theoretic foundations of most statistical paradigms, e g. Bayesian modeling, are rooted in calculating the expectation of a loss function (Robert and Casella, 2004).
Moreover, these expectations are often taken with respect to distributions whose densities are only known up to a normalizing constant, requiring some form of inference to be performed.
One such context is probabilistic programming (Gordon et al., 2014; Rainforth, 2017; van de Meent et al., 2018).
Here our program is typically speciﬁed (often indirectly) through an unnormalized density γ ( x ).
The role of system’s inference engine is now to approximate the normalized density π ( x ) = γ ( x ) /Z , where Z is a normalizing constant equal to the integral of γ ( x ) over all possible values of x .
Here if one wishes to calculate some expectation
E π ( x ) [ f ( x )], the standard pipeline is to construct such an approximation
ˆ π ( x ) independently of f ( x ), before using this approximation to in turn estimate the expectation.
Sometimes, f ( x ) is not yet known at the point of inference, such that this pipeline is inevitable.
However, in recent work considering a general estimation context (i.e. any arbitrary π ( x ) and f ( x )), Golinski et al.
; Rainforth et al.
(2020) showed that if f ( x ) is known upfront, then we can improve on this pipeline.
Namely, they showed that substantial gains can be achieved by using the information in f ( x ) to construct target-aware
Bayesian inference (TABI) estimators directly geared towards the target expectation.
However, current probabilistic programming languages (PPL) (Bingham et al., 2019;
Carpenter et al., 2017; Cusumano-Towner et al., 2019;
Ge et al., 2018; Salvatier et al., 2016;
Tran et al., 2016; Wood et al., 2014), in general, do not allow the explicit incorporation of a function f ( x ) into their inference calculations.
Most languages do not even have a direct consideration of including the deﬁnition of such a f ( x ) into the program deﬁnition.
Though a handful of papers (Nori et al., 2015; Narayanan et al., 2016; Staton et al., 2016; Zinkov and
Shan, 2017) have considered formalizations for the expectation deﬁned by a probabilistic program—typically through considering its return values—none of these do this from the perspective of directly targeting the calculation of this expectation.
As such, no existing language current supports generating estimates in a target–aware fashion.
To address this, we propose the concept of an expectation programming framework (EPF), deﬁning this as something which directly allows the deﬁnition of expectations and then automates their estimation using target-aware inference algorithms.
We further introduce a speciﬁc implementation of an expectation programming framework, called EPT (Expectation Programming in Turing), that is built upon the Turing PPL (Ge et al., 2018).
EPT takes as input Turing–style programs and uses program transformations to create a new set of valid Turing programs that are suitable for the construction of TABI estimators, exploiting the fact that the generalised TABI framework of (Rainforth et al., 2020) can repurpose any marginal likelihood estimator into a target-aware inference algorithm.
To realize the potential of EPT, we introduce a new annealed importance sampling (AnIS) (Neal, 2001) inference engine for Turing programs.
We then use it to show that our framework can be used to express real expectation problems, and empirically estimate them signiﬁcantly more accurately than the conventional probabilistic programming pipeline.
2. Background
We are concerned with computing expectation values of the form E π ( x ) [ f ( x )] where f ( x ) is known, but π ( x ) cannot be directly evaluated or sampled from.
Namely, π ( x ) = γ ( x ) /Z
where γ ( x ) is known unnormalized distribution, but Z is an unknown normalization constant.
The standard workﬂow to estimate E π ( x ) [ f ( x )] is to approximate π ( x ) (e.g. with
Monte Carlo samples)
and then use this to approximate the expectation in turn.
However, this pipeline is suboptimal if we know f ahead of time (Golinski et al., 2019).
The Target-Aware Bayesian Inference (TABI) framework (Rainforth et al., 2020) provides a means of creating an estimator for E π ( x ) [ f ( x )] that incorporates information from the target function f .
TABI breaks down the expectation into three diﬀerent parts
[Equation]
where
[Equation]
We can view the three subcomponents as the normalisation constants of the three densities
γ +1 ( x ) ∝ γ ( x ) f
+ ( x ), γ − 1 ( x ) ∝ γ ( x ) f − ( x ) and γ 2 ( x ) = γ ( x ), respectively.
Thus we can repurpose any algorithm which provides estimates of the normalisation constant into a
@expectation function expct(y) x ∼ MvNormal(zeros(length(y)), I)
# x ∼ N ( x ; 0 , I )
y ∼ MvNormal(x, I)
# y ∼ N
( y ; x , I ) return pdf(MvNormal(x, 0.5*I), -y)
# f ( x ) =
N ( − y ; x , 12 I ) end expct_estimate, diagnostics = estimate_expectation( expct(-2*ones(10)/sqrt(10)), method=
TABI( marginal_likelihood_estimator=TuringAlgorithm(AnIS(), num_samples=1000))) target-aware inference algorithm. Namely, we can break down the problem into these three densities, run a marginal likelihood estimator for each (returning ˆ Z +1 , ˆ Z − 1 , and ˆ Z 2 respectively), and then recombine these to an overall estimator as E π ( x ) [ f ( x )] ≈ ( ˆ Z +1 − ˆ Z − 1 ) /
ˆ Z 2 .
Throughout the next section we will rely on basic understanding of the Turing PPL (Ge et al., 2018) which we build upon.
For the relevant introduction to Turing, see Appendix B.
3. Expectation Programming in Turing
Probabilistic programs can be interpreted as deﬁning expectations over their return values (Gordon et al., 2014).
Current probabilistic programming language largely ignore these semantics and focus on approximating conditional distributions.
We propose the concept of Expectation Programming Framework (EPF) which exploits this fact to automate the use of target-aware inference algorithms.
We enable users to write expectation programs which deﬁne an expectation E π ( x ) [ f ( x )] by deﬁning an unnormalised density γ ( x )=
π ( x ) Z and a function f ( x ).
Our implementation of the EPF concept, Expectation Programming in Turing (EPT), allows users to specify γ ( x ) as they normally would using Turing @model macro, but it interprets the return semantics as deﬁning the integrand f ( x ).
Figure 1 shows how to deﬁne and estimate an expectation with EPT.
@expectation is an EPT macro, which is a drop-in replacement for the Turing @model macro, that allows
EPT to interpret the return semantics without any changes required to the function body with respect to the plain Turing model deﬁnition.
The expectation expct is estimated with the EPT function estimate_expectation(expct, method) where method speciﬁes the estimation method.
EPT implements algorithms which exploit the TABI framework.
As per
Section 2, TABI requires a choice of a marginal likelihood estimator.
In this example we use TABI with annealed importance sampling AnIS , which is a plain Turing inference algorithm.
Importantly, AnIS could be substituted with any other Turing inference algorithm that returns a marginal likelihood estimate.
In this example, AnIS() implies the use of some arbitrary default AnIS parameters regarding the Markov chain Monte Carlo (MCMC) algorithm, and the number and spacing of intermediate potentials used.
The ﬁnal element
@expectation function expct(y) x ∼ MvNormal(zeros(length(y)), I)
y ∼ MvNormal(x, I) return pdf(MvNormal(x, 0.5*I), -y) end @model function expct(y) x ∼ MvNormal(zeros(length(y)), I)
y ∼ MvNormal(x, I) tmp = pdf(MvNormal(x, 0.5*I), -y) @addlogprob!(log(max(tmp, 0))) return tmp end of the EPT API is TuringAlgorithm which is an object storing the necessary information that allows TABI to use a Turing inference method to estimate each of the three terms required by the TABI estimator.
We note that other implementations of the EPF concept can take advantage of other methods that make use of the knowledge of the target function f ( x ) to improve the process of estimation, in a similar way that diﬀerent PPLs focus on diﬀerent families of inference algorithms.
For example, we conceive EPF implementations which focus on the use of control variates or other variance reduction techniques.
3.1. Program Transformation
The TABI framework requires us to estimate the normalisation constants of the three densities γ 2 ( x ), γ +1 ( x ) and γ − 1 ( x ).
We use Julia’s metaprogramming capabilities to transform the user provided @expectation model deﬁnition into three valid Turing @model programs corresponding to each of these densities.
Since these are valid Turing models we can use any inference algorithm implemented in Turing that provides marginal likelihood estimates.
This is a big advantage because it means we do not require custom implementations of inference algorithms that are adapted to our framework.
Firstly, note that the functions used to deﬁne expectations using EPT are also valid Turing models, i.e., replacing @expectation with @model yields a valid Turing program.
Such a program corresponds to the density γ 2 ( x )= γ ( x ) without requiring any transformation.
To create a Turing program corresponding to γ +1 ( x ) we need to multiply the density of the unaltered Turing program γ ( x ) by max( f ( x ) , 0).
This is achieved using Turing’s @addlogprob!(z) primitive, which increments the (log) density of the current execution by an arbitrary value z .
Our program transformation is a pattern matching procedure that ﬁnds all the return expr statements in the function body and inserts a statement @addlogprob!(log(max(expr, 0))) before each one of them.
A concrete example of the program transformation is presented in Figure 2.
The transformation yielding density γ − 1 ( x ) is analogous, but inserts a statement @addlogprob!(log(-min(expr, 0))) instead.
4. Experiments
While EPT is able to use any inference algorithm in Turing that provides marginal likelihood estimates we found that none of the existing inference algorithms in Turing is powerful enough for our use cases.
For that reason we implemented a new inference engine for Turing which uses annealed importance samples (AnIS) (Neal, 2001).
Appendix F gives a brief introduction to AnIS.
AnIS requires the setting of two hyperparameters: an annealing schedule and a Markov chain Monte Carlo transition kernel.
Currently, users can choose between the Metropolis-Hastings (MH) transition kernel which is implemented using Turing’s AdvancedMH.jl (Turing Development Team, 2020) and the Hamiltonian Monte Carlo (HMC) transition kernel (Neal, 2011) which is built on AdvancedHMC.jl (Xu et al., 2020).
In our experiments we will use AnIS to refer to the non-target-aware setting of annealed importance sampling and target-aware annealed importance sampling (TAAnIS) to refer to the estimator that uses annealed importance sampling to separately estimate the marginal likelihoods described in Section 2.
To ensure a fair comparison we use the same setting of hyperparameters for the AnIS algorithm as we will for the separate estimators in TAAnIS.
To compare the performance of the two estimators we look at the relative squared error (RSE) ˆ δ :
= (ˆ µ − µ ) 2 µ, where µ denotes the ground truth value and ˆ µ is the estimate, and the eﬀective sample size (ESS).
In our experiments we only consider target functions which are always positive, so from here on we use Z 1 to refer to Z +1 because we always have Z − 1 = 0.
For TAAnIS we can look at the ESS of the two AnIS runs which we denote ESS Z 1 and
ESS Z 2 .
Similarly, ESS AnIS is the ESS for AnIS.
Note that we can also compute what the
ESS would be if we would use the samples from AnIS to estimate Z 1 by multiplying the importance weights produced by AnIS by f ( x ), we will denote the ESS computed in such a way by ESS AnIS retargeted .
4.1. Posterior Predictive
For our ﬁrst experiment we compare AnIS and TAAnIS on the the task of calculating the posterior predictive distribution of a Gaussian model with unknown mean.
Let
[Equation]
and
[Equation]
be our unnormalised density and target function.
We assume our observed data is y = 2 √ 10where 1 is a 10-dimensional vector of ones.
The implementation of this model in Figurehighlights the user–friendly interface of EPT.
The expectation can be deﬁned in just 5 lines of code as per Figure 1.
Figure 3 compares the performance of AnIS and TAAnIS.
Overall we can see that there is a clear beneﬁt of using the target-aware inference algorithm to estimate the expectation.
TAAnIS achieves a lower RSE and the ESS analysis highlights the advantage of using separate marginal likelihood estimators for Z 1 and Z 2 .
4.2. SIR Model
As a more applied example, assume we face an outbreak of a contagious disease.
The government has provided us with a function yielding the expected cost of the disease which depends on the basic reproduction rate R 0 .
To infer R
we choose to model the outbreak using a Susceptible-Infected-Recovered (SIR) model (Kermack et al., 1927).
This model divides the population into three compartments: people who are susceptible to the the disease, people who are currently infected, and people who have already recovered.
The dynamics of the outbreak are modelled by a set of diﬀerential equations which are governed by two parameters β and γ .
Roughly, β models the constant rate of infectious contact between people, while γ is the constant recovery rate of infected individuals.
From these parameters we can calculate the basic reproduction rate R 0 = βγ .
In our experiment, we assume γ to be ﬁxed and we want to infer β and the initial number of infected people I 0 .
For a full description of the model and the experimental setup, see Appendix H.
This scenario is a good use case for EPT because we are interested in estimating a speciﬁc expectation with high accuracy.
Furthermore, in this case there are some outcomes which might be unlikely under the posterior but which incur a very high cost.
By targeting only the posterior in our inference problem we run the danger of underestimating the probability of rare events which have a high cost and therefore underestimating the expected cost.
Figure 4 compares the performance of AnIS and TAAnIS for this problem.
The RSE of the AnIS estimate fails to improve at all in the range of samples we collected.
This is due to a strong mismatch between our target function and the posterior distribution.
AnIS generates samples only in the regions with high posterior density but not in the regions where the target function is large.
TABI methods were designed to overcome such a challenge.
Acknowledgments
We would like to thank Sheheryar Zaidi for helpful discussions on conﬁguring Annealed
Importance Sampling.
Tim Reichelt and Adam Golinski are supported by UK EPSRC
CDT in Autonomous Intelligent Machines and Systems.
Appendix A. Related Work
Nori et al.
(2015) introduce a C-like probabilistic programming language with a semantics that deﬁnes the meaning of probabilistic programs as the expected value of its return expression.
To construct a more eﬃcient MCMC kernel, they generate a new program which is a transformation of the user-deﬁned program.
Their program transformations preserve the meaning of the original program i.e. it deﬁnes the same expected value.
However, their end goal is to construct a more eﬃcient inference algorithm for the observed data opposed to constructing a more eﬃcient estimator for the given target expectation , which is the aim of our work.
Hakaru (Narayanan et al., 2016) provides the primitive expect(m, f) (Zinkov and Shan, 2017) which takes as input given a program deﬁning a measure and a function returns a program which represents the expectation over the measure with respect to the function.
However, this primitive is mainly used to get a symbolic representation of the expectation with the primary aim to compute the normalisation constant of unnormalised measures.
measures e.g. when conditioning a joint probability distribution on data.
With the help of a computer algebra solver the symbolic representation can be used to compute the integral analytically.
To our knowledge, our framework is the ﬁrst to use the semantics of probabilistic programs deﬁning expectations over their return expressions to generate target-aware inference algorithms .
Appendix B. A Short Introduction to Turing
We will present a brief overview of the Turing PPL and its internals.
For more details we refer the reader to the Turing documentation.
2 A Turing program is deﬁned similarly to a normal Julia (Bezanson et al., 2017) function: the @model macro indicates the deﬁnition of a Turing model which means we can use tilde statements to deﬁne random variables inside the function body e.g., x ∼ Normal(0, 1) (see Figure 5).
The left-hand side of the tilde statement must be a random variable, and the right-hand side must be a distribution.
The values of the observed random variables must be passed as arguments to the function.
The @model macro takes the function and creates a Turing model generator with the same name as the function.
If we call this model generator with some speciﬁc function arguments we get back a Turing model.
At that stage the tilde statements get resolved into calls to the primitives tilde_assume or tilde_observe .
The exact behaviour of those primitives usually depends on the inference algorithm that is used.
Here we will describe the behaviour of tilde_assume and tilde_observe when we want to evaluate the density of a raw random draw of the program.
The primitive tilde_observe(ctx, sampler, dist, value, vname, vinds, vi) gets called if the left-hand side of the tilde statement was part of the observed data (i.e. one of the formal parameters of the function).
dist will be a distribution, value will be a value in the support of that distribution, vi is a data structure which keeps track of the sampled values and the log density of the current execution and vname is the random variable identiﬁer i.e. the lexical address that is used to uniquely identify the random variable.
For the purpose of this document the other function arguments can be ignored.
Mainly, tilde_observe evaluates the log density of value under dist and adds the value to the log density stored in vi .
If the left-hand side of the tilde statement is not part of the observed data then the primitive tilde_assume(rng, ctx, sampler, dist, vname, inds, vi) gets called.
dist , vi and vname have the same types as in the tilde_observe call.
On a high-level tilde_assume samples a value from dist and then stores the sampled value in vi and adds the corresponding log density to the log density stored in vi .
Building on the notation of Rainforth (2017, Chapter 4.3) we can formalise the deﬁnitions of tilde_assume and tilde_observe .
tilde_assume takes as input a distribution which is constructed from a set of variables η , formally, g a ( x | η ) where a is the lexical address of the tilde_assume statement.
Similarly tilde_observe takes as input a distribution constructed from a set of variables φ and some observed random variables y , or formally, h b ( y | φ ) where b again is a lexical address.
Additionally, Turing also provides the @addlogprob!(x) primitive which increments the log density of the current execution by an arbitrary value x .
We let ψ 1 , . . .
, ψ K denote all the terms that are added to the density using @addlogprob! .
Given the above deﬁnitions the density of a Turing program is
[Equation]
Therefore the program in Figure 5 deﬁnes the density γ ( x ) =
N ( x ; 0 , 1) N ( y ; x, 1) where y is the observed data.
Note that there are no @addlogprob!(x) statements in this program.
Appendix C. A Note On the Formalization of f ( · )
To provide a valid input for our normalization constant estimators in the TABI framework, we need to be able to provide a valid density.
This also means we need to be careful about the random variable this density is deﬁned over.
When we construct, e.g., γ ( x ) + we are eﬀectively including an additional factor f + ( x ) to the program density (informally, an additional likelihood term).
As such, this density is deﬁned with respect to the raw random draws of the program, as per a conventional probabilistic program (see e.g. (Rainforth, 2017, Section 4.3)).
This means that the formal deﬁnition of f ( · ) is the full mapping from the raw random draws to the returned values, rather than what is lexically written after the return statement(s).
This is why, for example, it is still valid to have multiple diﬀerent return statements in program, provided these all return outputs of the same type and dimensionality.
In practice, this is not something we need to worry about when writing either models or inference engines, as the law of the unconscious statistician protects us from needing to carefully delineate between what our function is and what our random variable is.
Essentially, the output of the program is a random variable and we are calculating the expectation of this random variable; this expectation does not vary if we change the parameterization of our model.
However, the distinction is important from the perspective of ensuring that the approach is valid, both in terms of providing valid inputs to the individual TABI estimators, and in terms of ensuring the inference engines are valid for these problems.
Appendix D. Estimating Expectations in Turing
@model function model(y) x ∼ MvNormal(zeros(length(y)), I)
y ∼ MvNormal(x, I) end
D =y_observed = -2 * ones(D) / sqrt(D) num_samples =
posterior_samples = sample( model(y_observed), NUTS(0.65), num_samples) posterior_x = Array(posterior_samples[:x]) expectation_estimate
= mean( map(x -> pdf(MvNormal(x, 0.5*I), -y_observed), posterior_x))
Full example of the estimation of an expectation with the Turing language.
The user ﬁrst deﬁnes the model, then conditions it on some observed data, computes posterior samples and then uses these samples to compute a Monte Carlo estimate of the expectation.
Appendix E. Full Example of @expectation Macro Transformation
The expectation @expectation function expct(y) x ∼ MvNormal(zeros(length(y)), I)
y ∼ MvNormal(x, I) return pdf(MvNormal(x, 0.5*I), -y) end gets transformed into @model function gamma1_plus(y)
x ∼ MvNormal(zeros(length(y)), I)
y ∼ MvNormal(x, I) tmp = pdf(MvNormal(x, 0.5*I), -y)
@addlogprob!(log(max(tmp, 0))) return tmp end @model function gamma1_minus(y)
x ∼ MvNormal(zeros(length(y)), I)
y ∼ MvNormal(x, I) tmp = pdf(MvNormal(x, 0.5*I), -y) @addlogprob!(log(-min(tmp, 0)))
return tmp end @model function gamma2(y)
x ∼ MvNormal(zeros(length(y)), I)
y ∼ MvNormal(x, I) return pdf(MvNormal(x, 0.5*I), -y) end expct =
Expectation( gamma1_plus, gamma1_minus, gamma )
The type Expectation is simply used to have one common object which stores the three diﬀerent Turing models.
Notice that for gamma2 the function body is identical to the original function.
Appendix F. Annealed Importance Sampling
Annealed importance sampling (AnIS) (Neal, 2001) is an inference algorithm which was developed with the goal of eﬃciently estimating the normalisation constant Z of an unnormalised density γ ( x ).
It works by deﬁning a sequence of annealing distributions π 0 ( x ) , . . .
, π n ( x ) which anneal between a simple (i.e. we can sample from it and evaluate its density) base distribution π 0 ( x ) and the complex target density π n ( x ) = γ ( x ).
The most common scheme for deﬁning the annealing distributions is to set them to π i ( x )
∝ λ i ( x )
= p ( x ) 1 − β n γ ( x ) β n , with p ( x ) being the prior distribution and 0 = β 0 < β 1 < · · · < β n = 1.
Furthermore, the algorithm requires the deﬁnition of Markov chain transition kernels τ 1 ( x, x (cid:48) ) , . . .
, τ n − 1 ( x, x (cid:48) ).
Each τ i ( x, x (cid:48) ) needs to leave its target distribution
λ i ( x ) invariant.
The algorithm to create a j th single weighted sample then becomes:
Sample initial particle x (1) j ∼ π 0 ( x ) 2.
For i = 1 , . . .
, ( n − 1): Generate x ( i +1)
j
[Equation]
i [Equation] ( i ) j , · )
Return sample x ( n ) j with weight
[Equation]
We can estimate expectations with the weights and samples just as in standard importance sampling.
Thus an estimate for the normalisation constant is
[Equation]
and an estimate for the expectation is
[Equation]
Appendix G. Hyperparameters for Experiments
For both problems our target function is always positive which means in the TABI estimator we only have to compute Z +1 and Z 2 because Z − 1 = 0.
Therefore, target-aware annealed importance sampling (TAAnIS) runs standard annealed importance sampling twice, one time to estimate Z +1 and the other time to estimate Z 2 .
For the experiments, on the same problem we always use the same hyperparameters for the annealed importance sampling algorithm both to run AnIS and for the two estimates in TAAnIS.
G.1. Posterior Predictive
For the annealed importance sampling we use a MH transition kernel with a standard normal as the proposal and 20 MH steps on each annealing distribution.
We useannealing distributions uniformly spaced.
G.2. SIR Model
For the annealed importance sampling estimators we use HMC transition kernels with a step size of 0.05, 10 leapfrog steps and 10 MCMC steps on each annealing distribution.
We use 100 geometrically spaced annealing distributions.
The ground truth is computed using importance sampling with 10 8 samples and the prior as a proposal distribution.
See Equation (4) for the full SIR model including the priors.
Appendix H. SIR Experiment
The SIR model assumes the population is divided into three compartments: susceptible (people not yet infected), infected and recovered (people who already had the disease).
Apart from a number of initially infected people I 0 , every person in the population starts out as susceptible, then potentially becomes infected and then recovers after some time.
Crucially, the SIR model makes some simplifying assumptions most notably that a recovered person cannot get infected again and that the total number of people in the population remains constant.
The SIR model can be succinctly described by the following set of ordinary diﬀerential equations (ODE):
[Equation]
For our case we assume that γ = 0 .
25 is known and need not be inferred from data.
Therefore our model has two unknown parameters: the initial number of infected patients
I 0 and β .
We assume we are given data in the form of observations
y i , the number of observed newly infected people on day i .
This gives us the statistical model
[Equation]
Here ODESolve indicates a call to an ODE solver which solves the set of equations (3).
It outputs x i the predicted number of newly infected people on day i .
Since we assume that we have noisy observations we use a negative Binomial to add some noise to the predictions from the diﬀerential equations.
The negative binomial NegBinomial( µ, φ ) is parametrised by its mean µ and an overdispersion parameter φ ; for φ → ∞ the negative binomial distribution approaches a Poisson distribution.
For an in-depth discussion about doing Bayesian parameter inference in the SIR model we refer the reader to the case study of Grinsztajn et al.
We assume we are given a cost function in terms of the basic reproduction rate, cost( R 0 )
= 1 e 12 ∗ logistic(10 R 0 − 30) .