The Zig-Zag Process and Super-Efficient Sampling for Bayesian Analysis of Big Data

Joris Bierkens, Paul Fearnhead, Gareth Roberts

Introduction

The importance of Markov chain Monte Carlo techniques in Bayesian inference shows no signs of diminishing. However, all commonly used methods are variants on the Metropolis-Hastings (MH) algorithm Metropolis et al. 1953; Hastings 1970 and rely on innovations which date back over 60 years. All MH algorithms simulate realisations from a discrete reversible ergodic Markov chain with invariant distribution π\pi which is (or is closely related to) the target distribution, i.e. the posterior distribution in a Bayesian context. The MH algorithm gives a beautifully simple though flexible recipe for constructing such Markov chains, requiring only local information about π\pi (typically pointwise evaluations of π\pi and, perhaps, its derivative at the current and proposed new locations) to complete each iteration.

However new complex modelling and data paradigms are seriously challenging these established methodologies. Firstly, the restriction of traditional MCMC to reversible Markov chains is a serious limitation. It is now well-understood both theoretically Hwang, Hwang-Ma and Sheu 1993; Chen and Hwang 2013; Rey-Bellet and Spiliopoulos 2015; Bierkens 2015; Duncan, Lelièvre and Pavliotis 2016 and heuristically Neal 1998 that non-reversible chains offer potentially massive advantages over reversible counterparts. The need to escape reversibility, and create momentum to aid mixing throughout the state space is certainly well-known, and motivates a number of modern MCMC methods, including the popular Hamiltonian MCMC Duane et al. 1987.

A second major obstacle to the application of MCMC for Bayesian inference is the need to process potentially massive data-sets. Since MH algorithms in their pure form require a likelihood evaluation – and thus processing the full data-set – at every iteration, it can be impractical to carry out large numbers of MH iterations. This has led to a range of alternatives that use sub-samples of the data at each iteration Welling and Teh 2011; Maclaurin and Adams 2014; Ma, Chen and Fox 2015; Quiroz, Villani and Kohn 2015, or that partition the data into shards, run MCMC on each shard, and then attempt to combine the information from these different MCMC runs Neiswanger, Wang and Xing 2013; Scott et al. 2016; Wang and Dunson 2013; Li, Srivastava and Dunson 2017. However most of these methods introduce some form of approximation error, so that the final sample will be drawn from some approximation to the posterior, and the quality of the approximation can be impossible to evaluate. As an exception the Firefly algorithm Maclaurin and Adams 2014 samples from the exact distribution of interest (but see the comment below).

This paper introduces the multi-dimensional Zig-Zag sampling algorithm (ZZ) and its variants. These methods overcome the restrictions of the lifted Markov chain approach of Turitsyn, Chertkov and Vucelja 2011 as they do not depend on the introduction of momentum generating quantities. They are also amenable to the use of sub-sampling ideas. The dynamics of the Zig-Zag process depends on the target distribution through the gradient of the logarithm of the target. For Bayesian applications this is a sum, and is easy to estimate unbiasedly using sub-sampling. Moreover, Zig-Zag with Sub-Sampling (ZZ-SS) retains the exactness of the required invariant distribution. Furthermore, if we also use control variate ideas to reduce the variance of our sub-sampling estimator of the gradient, the resulting Zig-Zag with Control Variates (ZZ-CV) algorithm has remarkable super-efficient scaling properties for large data sets.

We will call an algorithm super-efficient if it is able to generate independent samples from the target distribution at a higher efficiency than if we would draw independently from the target distribution at the cost of evaluating all data. The only situation we are aware of where we can implement super-efficient sampling is with simple conjugate models, where the likelihood function has a low-dimensional summary statistic which can be evaluated at cost O(n)O(n), where nn is the number of observations, after which we can obtain independent samples from the posterior distribution at a cost of O(1)O(1) by using the functional form of the posterior distribution. The ZZ-CV can replicate this computational efficiency: after a pre-computation of O(n)O(n), we are able to obtain independent samples at a cost of O(1)O(1). In this sense it contrasts with the Firefly algorithm Maclaurin and Adams 2014 which has an ESS per datum which decreases approximately as 1/n1/n where nn is the size of the data, so that the gains of this algorithm do not increase with nn; see (Bouchard-Côté, Vollmer and Doucet 2015, Section 4.6).

The use of PDMPs such as the Zig-Zag processes is an exciting and mostly unexplored area in MCMC. The first occurrence of a PDMP for sampling purposes is in the computational physics literature Peters and De With 2012, which in one dimension coincides with the Zig-Zag process. In Bouchard-Côté, Vollmer and Doucet 2015 this method is given the name Bouncy Particle Sampler. In multiple dimensions the Zig-Zag process and Bouncy Particle Sampler (BPS) are different processes: both are PDMPs which move along straight line segments, but the Zig-Zag process changes direction in only a single component at each switch, whereas the Bouncy Particle Sampler reflects the full direction vector in the level curves of the density function. As we will see in Section 2.4, this difference has a beneficial effect on the ergodic properties of the Zig-Zag process. The one-dimensional Zig-Zag process is analysed in detail in e.g. Fontbona, Guérin and Malrieu 2012; Monmarché 2014; Fontbona, Guérin and Malrieu 2016; Bierkens and Roberts 2017.

Since the first version of this paper was conceived already several other related theoretical and methodological papers have appeared. In particular we mention here results on exponential ergodicity of the BPS Deligiannidis, Bouchard-Côté and Doucet 2017 and ergodicity of the multi-dimensional Zig-Zag process Bierkens, Roberts and Zitt 2017. The Zig-Zag process has the advantage that it is ergodic under very mild conditions, which in particular means that we are not required to choose a refreshment rate. At the same time, the BPS seems more ‘natural’, in that it tries to minimise the bounce rate and the change in direction at bounces, and it may be more efficient for this reason. However it is a challenge to make a direct comparison in efficiency of the two methods since the efficiency depends both on the computational effort per unit of continuous time of the respective algorithms, as well as the mixing time of the underlying processes. Therefore we expect analysing the relative efficiency of PDMP based algorithms to be an important area of continued research for years to come.

A continuous-time sequential Monte Carlo algorithm for scalable Bayesian inference with big data, the SCALE algorithm, is given in Pollock et al. 2016. Advantages that Zig-Zag has over SCALE is that it avoids the issue of controlling the stability of importance weights, and it is simpler to implement. Whereas the SCALE algorithm is well-adapted for the use of parallel architecture computing, and has particularly simple scaling properties for big data.

The Zig-Zag process

For a given (ξ,θ)∈E(\xi,\theta)\in E, we may construct a trajectory of (Ξ,Θ)(\Xi,\Theta) of the Zig-Zag process with initial condition (ξ,θ)(\xi,\theta) as follows.

Let (T0,Ξ0,Θ0):=(0,ξ,θ)(T^{0},\Xi^{0},\Theta^{0}):=(0,\xi,\theta).

Let ξk(t):=Ξk−1+Θk−1t\xi^{k}(t):=\Xi^{k-1}+\Theta^{k-1}t, t≥0t\geq 0

For i=1,…,di=1,\dots,d, let τik\tau^{k}_{i} be distributed according to

Let i0:=argmin⁡i∈{1,…,d}τiki_{0}:=\operatorname{argmin}_{i\in\{1,\dots,d\}}\tau^{k}_{i} and let Tk:=Tk−1+τi0kT^{k}:=T^{k-1}+\tau^{k}_{i_{0}}.

The piecewise deterministic trajectories (Ξ(t),Θ(t))(\Xi(t),\Theta(t)) are now obtained as

Since the switching rates are continuous and hence bounded on compact sets, and Ξ\Xi will travel a finite distance within any finite time interval, within any bounded time interval there will be finitely many switches almost surely.

The above procedure provides a mathematical construction of a Markov process as well as the outline of an algorithm which simulates this process. The only step in this procedure which presents a computational challenge is the simulation of the random times (Tik)(T_{i}^{k}) and a significant part of this paper will consider obtaining these in a numerically efficient way.

Figure 1 displays trajectories of the Zig-Zag process for several examples of invariant distributions. The name of the process is derived by the zig-zag nature of paths that the process produces. Figure 1 shows an important difference in the output of the Zig-Zag process, as compared to a discrete-time MCMC algorithm: the output of is a continuous-time sample path. The bottom row of plots in Figure 1 also gives a comparison to a reversible MCMC algorithm, Metropolis Adjusted Langevin (Roberts and Tweedie 1996, MALA), and demonstrates an advantage of a non-reversible sampler: it can cope better with a heavy tailed target. This is most easily seen if we start the process out in the tail, as in the figure. The velocity component of the Zig-Zag process enables it to quickly return to the mode of the distribution, whereas the reversible algorithm behaves like a random walk in the tails, and takes much longer to return to the mode.

2 Invariant distribution

Suppose Assumption 2.1 holds. Let μ\mu denote the probability distribution on EE such that μ\mu has Radon-Nikodym derivative

where Z=∫Eexp⁡(−Ψ) dμ0Z=\int_{E}\exp(-\Psi)\ d\mu_{0}. Then the Zig-Zag process (Ξ,Θ)(\Xi,\Theta) with switching rates (λi)i=1d(\lambda_{i})_{i=1}^{d} has invariant distribution μ\mu.

The proof is located in the Section 1 of the Supplementary Material. We see that under the invariant distribution of the Zig-Zag process, ξ\xi and θ\theta are independent, with ξ\xi having density proportional to exp⁡(−Ψ(ξ))\exp(-\Psi(\xi)) and θ\theta having a uniform distribution on the points in {−1,+1}d\{-1,+1\}^{d}.

The proof is located in Section 1 of the Supplementary Material.

3 Zig-Zag process for Bayesian inference

One application of the Zig-Zag process is as an alternative to MCMC for sampling from posterior distributions in Bayesian statistics. We show here that it is straightforward to derive a class of Zig-Zag processes that have a given posterior distribution as their invariant distribution. The dynamics of the Zig-Zag process only depend on knowing the posterior density up to a constant of proportionality.

We can write π(ξ)\pi(\xi) in the form of the previous section,

will have the posterior density π(ξ)\pi(\xi) as the marginal of its invariant distribution. We call the process with these rates the Canonical Zig-Zag process for the negative log density Ψ\Psi. As explained in Proposition 2.3, we can construct a family of Zig-Zag processes with the same invariant distribution by choosing any set of functions γi(ξ,θ)\gamma_{i}(\xi,\theta), for i=1,…,di=1,\ldots,d, which take non-negative values and for which γi(ξ,θ)=γi(ξ,Fi[θ])\gamma_{i}(\xi,\theta)=\gamma_{i}(\xi,F_{i}[\theta]), and setting

The intuition here is that λi(ξ,θ)\lambda_{i}(\xi,\theta) is the rate at which we transition from θ\theta to Fi[θ]F_{i}[\theta]. The condition γi(ξ,θ)=γi(ξ,Fi[θ])\gamma_{i}(\xi,\theta)=\gamma_{i}(\xi,F_{i}[\theta]) means that we increase by the same amount both the rate at which we will transition from θ\theta to Fi[θ]F_{i}[\theta] and vice versa. As our invariant distribution places the same probability of being in a state with velocity θ\theta as that of being in state Fi[θ]F_{i}[\theta], these two changes in rate cancel out in terms of their effect on the invariant distribution. Changing the rates in this way does impact the dynamics of the process, with larger γi\gamma_{i} values corresponding to more frequent changes in the velocity of the Zig-Zag process, and we would expect the resulting process to mix more slowly.

for any initial condition (ξ,θ)∈E(\xi,\theta)\in E. Sufficient conditions for ergodicity will be discussed in the following section. Taking γ\gamma to be positive and bounded everywhere ensures ergodicity, as will be established in Theorem 2.10.

4 Ergodicity of the Zig-Zag process

Ergodicity is directly related to the requirement that (Ξ(t),Θ(t))(\Xi(t),\Theta(t)) is irreducible, i.e. the state space is not reducible into components which are each invariant for the process (Ξ(t),Θ(t))(\Xi(t),\Theta(t)). For the one-dimensional Zig-Zag process, (exponential) ergodicity has already been established under mild conditions Bierkens and Roberts 2017. As we discuss below, irreducibility, and thus ergodicity, can be established for large classes of multi-dimensional target distributions, such as i.i.d. Gaussian distributions, and also if the switching rates λi(ξ,θ)\lambda_{i}(\xi,\theta) are positive for all i=1,…,di=1,\dots,d, and (ξ,θ)∈E(\xi,\theta)\in E.

Suppose d=1d=1 and there exists ξ0>0\xi_{0}>0 such that

inf⁡ξ≥ξ0λ(ξ,+1)>sup⁡ξ≥ξ0λ(ξ,−1)\inf_{\xi\geq\xi_{0}}\lambda(\xi,+1)>\sup_{\xi\geq\xi_{0}}\lambda(\xi,-1), and

inf⁡ξ≤−ξ0λ(ξ,−1)>sup⁡ξ≤−ξ0λ(ξ,+1)\inf_{\xi\leq-\xi_{0}}\lambda(\xi,-1)>\sup_{\xi\leq-\xi_{0}}\lambda(\xi,+1).

(Bierkens and Roberts 2017, Theorem 5) Suppose Assumption 2.4 holds. Then there exists a function f:E→[1,∞)f:E\rightarrow[1,\infty) which is norm-like such that the Zig-Zag process is ff-exponentially ergodic, i.e. there exists a constant κ>0\kappa>0 and 0<ρ<10<\rho<1 such that

As an example of fundamental importance, which will also be used in the proof of Theorem 2.10, consider a one-dimensional Gaussian distribution. For simplicity let π(ξ)\pi(\xi) be centred, π(ξ)=12πσ2exp⁡(−ξ22σ2)\pi(\xi)=\frac{1}{\sqrt{2\pi\sigma^{2}}}\exp\left(-\frac{\xi^{2}}{2\sigma^{2}}\right) for some σ>0\sigma>0. According to (4) the switching rates take the form

As long as γ\gamma is bounded from above, Assumption 2.4 is satisfied. In particular this holds if γ\gamma is equal to a non-negative constant.

As long as γi(ξ)=γi(ξi)\gamma_{i}(\xi)=\gamma_{i}(\xi_{i}), i.e. if γi(ξ)\gamma_{i}(\xi) only depends on the ii-th coordinate of ξ\xi, the switching rate of coordinate ii is independent of the other coordinates ξj\xi_{j}, j≠ij\neq i. It follows that the switches of the ii-th coordinate can be generated by a one-dimensional time inhomogeneous Poisson process, which is independent of the switches in the other coordinates. As a consequence the dd-dimensional Zig-Zag process (Ξ(t),Θ(t))=(Ξ1(t),…,Ξd(t),Θ1(t),…,Θd(t))(\Xi(t),\Theta(t))=(\Xi^{1}(t),\dots,\Xi_{d}(t),\Theta^{1}(t),\dots,\Theta^{d}(t)) consists of a combination of dd independent Zig-Zag processes (Ξi(t),Θi(t))(\Xi^{i}(t),\Theta^{i}(t)), i=1,…,di=1,\dots,d.

Suppose P(x,dy)P(x,dy) is the transition kernel of a Markov chain on a state space EE. We say that the Markov chain associated to PP is mixing if there exists a probability distribution π\pi on EE such that

For any continuous time Markov process with family of transition kernels Pt(x,dy)P^{t}(x,dy) we can consider the associated time-discretized process, which is a Markov chain with transition kernel Q(x,dy):=Pδ(x,dy)Q(x,dy):=P^{\delta}(x,dy) for a fixed δ>0\delta>0. The value of δ\delta will be of no significance in our use of this construction.

This follows from the decomposition of the dd-dimensional Zig-Zag process as dd one-dimensional Zig-Zag processes and Lemma 1.1 in the Supplementary material. ∎

Continuing Example 2.6, consider the simple case in which π\pi is of product form with each πi\pi_{i} a centered Gaussian density function with variance σi2\sigma_{i}^{2}. It follows from Proposition 2.8 and Example 2.6 that the multi-dimensional canonical Zig-Zag process (i.e. the Zig-Zag process with γi≡0\gamma_{i}\equiv 0) is mixing. This is different from the Bouncy Particle Sampler Bouchard-Côté, Vollmer and Doucet 2015, which is not ergodic for an i.i.d. Gaussian without ‘refreshments’ of the momentum variable.

We now show that strict positivity of the rates ensures ergodicity.

Suppose λ:E→(0,∞)d\lambda:E\rightarrow(0,\infty)^{d}, in particular λi(ξ,θ)\lambda_{i}(\xi,\theta) is positive for all i=1,…,di=1,\dots,d and (ξ,θ)∈E(\xi,\theta)\in E. Then there exists at most a single invariant measure for the Zig-Zag process with switching rate λ\lambda.

The proof of this result consists of a Girsanov change of measure with respect to a Zig-Zag process targeting an i.i.d. standard normal distribution, which we know to be irreducible. The irreducibility then carries over to the Zig-Zag process with the stated switching rates. A detailed proof can be found in the Supplementary material.

Based on numerous experiments, we conjecture that the canonical multi-dimensional Zig-Zag process is ergodic in general under only mild conditions. A detailed investigation of ergodicity will be the subject of a forthcoming paper Bierkens, Roberts and Zitt 2017.

Implementation

As mentioned earlier, the main computational challenge is an efficient simulation of the random times TikT^{k}_{i} introduced in Section 2.1. We will focus on simulation by means of Poisson thinning.

Now for a given initial point (ξ,θ)∈E(\xi,\theta)\in E, let mi(t):=λi(ξ+θt,θ)m_{i}(t):=\lambda_{i}(\xi+\theta t,\theta), for i=1,…,di=1,\dots,d, and suppose we have available continuous functions Mi(t)M_{i}(t) such that mi(t)≤Mi(t)m_{i}(t)\leq M_{i}(t) for i=1,…,di=1,\dots,d and t≥0t\geq 0. We call these (Mi)i=1d(M_{i})_{i=1}^{d} computational bounds for (mi)i=1d(m_{i})_{i=1}^{d}. We can use Proposition 3.1 to obtain the first switching times (τ~i1)i=1d(\widetilde{\tau}^{1}_{i})_{i=1}^{d} from a (theoretically infinite) collection of proposed switching times (τi1,τi2,… )i=1d(\tau^{1}_{i},\tau^{2}_{i},\dots)_{i=1}^{d} given the initial point (ξ,θ)(\xi,\theta), and use the obtained skeleton point at time τ~1:=min⁡i∈{1,…,d}τ~i1\widetilde{\tau}^{1}:=\min_{i\in\{1,\dots,d\}}\widetilde{\tau}_{i}^{1} as a new initial point (which is allowed by the strong Markov property) with the component i0=argmin⁡i∈{1,…,d}τ~i1i_{0}=\operatorname{argmin}_{i\in\{1,\dots,d\}}\widetilde{\tau}_{i}^{1} of θ\theta switched.

The strong Markov property of the Zig-Zag process simplifies the computational procedure further: we can draw for each component i=1,…,di=1,\dots,d the first proposed switching time τi:=τi1\tau_{i}:=\tau_{i}^{1}, determine i0:=argmin⁡i∈{1,…,d}τii_{0}:=\operatorname{argmin}_{i\in\{1,\dots,d\}}\tau_{i} and decide whether the appropriate component of θ\theta is switched at this time with probability mi0(τ)/Mi0(τ)m_{i_{0}}(\tau)/M_{i_{0}}(\tau), where τ:=τi0\tau:=\tau_{i_{0}}. Then since τ\tau is a stopping time for the Markov process, we can use the obtained point of the Zig-Zag process at time τ\tau as new starting point, regardless of whether we switch a component of θ\theta at the obtained skeleton point. A full computational procedure for simulating the Zig-Zag process is given by Algorithm 1.

We now come to the important issue of obtaining computational bounds for the Zig-Zag Process, i.e. useful upper bounds for the switching rates (mi)(m_{i}). If we can compute the inverse function Gi(y):=inf⁡{t≥0:Hi(t)≥y}G_{i}(y):=\inf\{t\geq 0:H_{i}(t)\geq y\} of Hi:t↦∫0tMi(s) dsH_{i}:t\mapsto\int_{0}^{t}M_{i}(s)\ ds, we can simulate τ1,…,τd\tau_{1},\dots,\tau_{d} using the CDF inversion technique, i.e. by drawing i.i.d. uniform random variables U1,…,UdU_{1},\dots,U_{d} and setting τi:=Gi(−log⁡Ui)\tau_{i}:=G_{i}(-\log U_{i}), i=1,…di=1,\dots d.

The computational bounds are directly related to the algorithmic efficiency of Zig-Zag Sampling. From Algorithm 1, it is clear that for every simulated time τ\tau a single component of λ\lambda needs to be evaluated, which corresponds by (4) to the evaluation of a single component of the gradient of the negative log density Ψ\Psi. The magnitude of the computational bounds, (Mi)(M_{i}), will determine how far the Zig-Zag process will have moved in the state space before a new evaluation of a component of λ\lambda is required, and we will pay close attention to the scaling of MiM_{i} with respect to the number of available observations in a Bayesian inference setting.

2 Example: globally bounded log density gradient

Algorithm 1 may be used with Mi≡ciM_{i}\equiv c_{i} for i=1,…,di=1,\dots,d at every iteration.

This situation arises with heavy-tailed distributions. E.g. if π\pi is Cauchy, then Ψ(ξ)=log⁡(1+ξ2)\Psi(\xi)=\log(1+\xi^{2}), and consequently λ(ξ,θ)=(2θξ1+ξ2)+≤1\lambda(\xi,\theta)=\left(\frac{2\theta\xi}{1+\xi^{2}}\right)^{+}\leq 1.

3 Example: negative log density with dominated Hessian

Applying this inequality we obtain for i=1,…,di=1,\dots,d,

Hence the general Zig-Zag Algorithm may be applied taking

with aia_{i} and bib_{i} as specified above. A complete procedure for Zig-Zag Sampling for a log density with dominated Hessian is provided in Algorithm 2.

It is also possibly to apply inequality (6) in such a way as to obtain the estimate

This requires us to compute QθQ\theta whenever θ\theta changes (a computation of O(d)O(d)).

Big data Bayesian inference by means of error-free sub-sampling

Throughout this section we assume the derivatives of Ψ\Psi admit the representation

where Ψj(ξ)=−log⁡π0(ξ)−nlog⁡f(xj∣ξ)\Psi^{j}(\xi)=-\log\pi_{0}(\xi)-n\log f(x^{j}|\xi), and we could choose Eij(ξ)=∂iΨj(ξ)E_{i}^{j}(\xi)=\partial_{i}\Psi^{j}(\xi). It is crucial that every EijE_{i}^{j} is a factor O(n)O(n) cheaper to evaluate than the full derivative ∂iΨ(ξ)\partial_{i}\Psi(\xi).

We will describe two successive improvements over the basic Zig-Zag Sampling (ZZ) algorithm specifically tailored to the situation in which (7) is satisfied. The first improvement consists of a sub-sampling approach where we need calculate only one of the EijsE_{i}^{j}s at each simulated time, rather than sum of all nn of them. This sub-sampling approach (referred to as Zig-Zag with Sub-Sampling, ZZ-SS) comes at the cost of an increased computational bound. Our second improvement is to use control variates to reduce this bound, resulting in the Zig-Zag with Control Variates (ZZ-CV) algorithm.

Let (ξ(t))t≥0(\xi(t))_{t\geq 0} denote a linear trajectory originating in (ξ,θ)∈E(\xi,\theta)\in E, i.e. ξ(t)=ξ+θt\xi(t)=\xi+\theta t. Define a collection of switching rates along the trajectory (ξ(t))(\xi(t)) by

Algorithm 3 generates a skeleton of a Zig-Zag process with switching rates given by

and invariant distribution μ\mu given by (3).

Conditional on τ\tau, the probability that component i0i_{0} of θ\theta is switched at time τ\tau is seen to be

By Proposition 3.1 we thus have an effective switching rate λi\lambda_{i} for switching the ii-th component of θ\theta given by (10). Finally we verify that the switching rates (λi)(\lambda_{i}) given by (10) satisfy (2). Indeed,

By Theorem 2.2, the Zig-Zag process has the stated invariant distribution. ∎

The important advantage of using Zig-Zag in combination with sub-sampling is that at every iteration of the algorithm we only have to evaluate a single component of EijE^{j}_{i}, which reduces algorithmic complexity by a factor O(n)O(n). However this may come at a cost. Firstly, the computational bounds (Mi)(M_{i}) may have to be increased which in turn will increase the algorithmic complexity of simulating the Zig-Zag sampler. Also, the dynamics of the Zig-Zag process will change, because the actual switching rates of the process are increased. This increases the diffusivity of the continuous time Markov process, and affects the mixing properties in a negative way.

2 Zig-Zag with Sub-Sampling (ZZ-SS) for globally bounded log density gradient

A straightforward application of sub-sampling is possible if we have (8) with ∇Ψj\nabla\Psi^{j} globally bounded, i.e. there exist positive constants (ci)(c_{i}) such that

so that (9) is satisfied. The corresponding version of Algorithm 3 will be called Zig-Zag with Sub-Sampling (ZZ-SS).

3 Zig-Zag with Control Variates (ZZ-CV)

The reason for defining Eij(ξ)E_{i}^{j}(\xi) in this manner is to try and reduce its variability as we vary jj. By the Lipschitz condition we have Eij(ξ)≤∣∂iΨ(ξ⋆)∣+Ci∥ξ−ξ⋆∥pE_{i}^{j}(\xi)\leq|\partial_{i}\Psi(\xi^{\star})|+C_{i}\|\xi-\xi^{\star}\|_{p}, and thus the variability of the Eij(ξ)E_{i}^{j}(\xi)s will be small if 1) the reference point ξ⋆\xi^{\star} is close to the mode of the posterior and 2) ξ\xi is close to ξ⋆\xi^{\star}. Under standard asymptotics we expect a draw from the posterior for ξ\xi to be Op(n−1/2)O_{p}(n^{-1/2}) from the posterior mode. Thus if we have a procedure for finding a reference point ξ⋆\xi^{\star} which is within O(n−1/2)O(n^{-1/2}) of the posterior mode then this would ensure ∥ξ−ξ⋆∥2\|\xi-\xi^{\star}\|_{2} is Op(n−1/2)O_{p}(n^{-1/2}) if ξ\xi is drawn from the posterior. For such a choice of ξ⋆\xi^{\star} we would have ∂iΨ(ξ⋆)\partial_{i}\Psi(\xi^{\star}) of Op(n1/2)O_{p}(n^{1/2}).

Using the Lipschitz condition, we can now obtain computational bounds of (mi)(m_{i}) for a trajectory ξ(t):=ξ+θt\xi(t):=\xi+\theta t originating in (ξ,θ)(\xi,\theta). Define

where ai:=(θi∂iΨ(ξ⋆))++Ci∥ξ−ξ⋆∥pa_{i}:=\left(\theta_{i}\partial_{i}\Psi(\xi^{\star})\right)^{+}+C_{i}\|\xi-\xi^{\star}\|_{p} and bi:=Cid1/pb_{i}:=C_{i}d^{1/p}. Then (9) is satisfied. Indeed, using Lipschitz continuity of y↦(y)+y\mapsto(y)^{+},

Implementing this scheme requires some pre-processing of the data. First we need a way of choosing a suitable reference point ξ⋆\xi^{\star} to find a value close to the mode using an approximate or exact numerical optimization routine. The complexity of this operation will be O(n)O(n). Once we have found such a reference point we have an one-off O(n)O(n) cost of calculating ∂iΨ(ξ⋆)\partial_{i}\Psi(\xi^{\star}) for each i=1,…,di=1,\ldots,d. However, once we have paid this upfront computational cost, the resulting Zig-Zag sampler can be super-efficient. This is discussed in more detail in Section 5, and demonstrated empirically in Section 6. The version of Algorithm 3 resulting from this choice of EijE^{j}_{i} and MiM_{i} will be called Zig-Zag with Control Variates (ZZ-CV).

When choosing p≥1p\geq 1, there will be a trade-off between the magnitude of CiC_{i} and of ∥ξ−ξ⋆∥p\|\xi-\xi^{\star}\|_{p}, which may influence the scaling of Zig-Zag sampling with dimension. We will see in Section 6.3 that for i.i.d. Gaussian components, the choice p=∞p=\infty is optimal. When the situation is less clear, choosing the Euclidean norm (p=2p=2) is a reasonable choice.

Scaling analysis

where xjx^{j} are i.i.d. drawn from f(xj∣ξ0)f(x^{j}\mid\xi_{0}). Let ξ^\widehat{\xi} denote the maximum likelihood estimator (MLE) for ξ\xi based on data x1,…,xnx^{1},\ldots,x^{n}. Introduce the coordinate transformation

As n→∞n\rightarrow\infty the posterior distribution in terms of ϕ\phi will converge to a multivariate Gaussian distribution with mean 0 and covariance matrix given by the inverse of the expected information i(θ0)i(\theta_{0}); see e.g. Johnson 1970.

First let us obtain a Taylor expansion of the switching rate for ξ\xi close to ξ^\widehat{\xi}. We have

The first term vanishes by the definition of the MLE. Expressed in terms of ϕ\phi, the switching rates are

With respect to the coordinate ϕ\phi, the canonical Zig-Zag process has constant speed n\sqrt{n} in each coordinate, and by the above computation, a switching rate of O(n)O(\sqrt{n}). After a rescaling of the time parameter by a factor n\sqrt{n}, the process in the ϕ\phi-coordinate becomes a Zig-Zag process with unit speed in every direction and switching rates

If we let n→∞n\rightarrow\infty, the switching rates converge almost surely to those of a Zig-Zag process with switching rates

where i(θ0)i(\theta_{0}) denotes the expected information. These switching rates correspond to the limiting Gaussian distribution with covariance matrix (i(θ0))−1(i(\theta_{0}))^{-1}.

In this limiting Zig-Zag process, all dependence on nn has vanished. Starting from equilibrium, we require a time interval of O(1)O(1) (in the rescaled time) to obtain an essentially independent sample. In the original time scale this corresponds to a time interval of O(n−1/2)O(n^{-1/2}). As long as the computational bound in the Zig-Zag algorithm is O(n1/2)O(n^{1/2}), this can be achieved using O(1)O(1) proposed switches. The computational cost for every proposed switch is O(n)O(n), because the full data (xi)i=1n(x^{i})_{i=1}^{n} needs to be processed in the computation of the true switching rate at the proposed switching time.

We conclude that the computational complexity of the Zig-Zag (ZZ) algorithm per independent sample is O(n)O(n), provided that the computational bound is O(n1/2)O(n^{1/2}). This is the best we can expect for any standard Monte Carlo algorithm (where we will have a O(1)O(1) number of iterations, but each iteration is O(n)O(n) in computational cost).

To compare, if the computational bound is O(nα)O(n^{\alpha}) for some α>1/2\alpha>1/2, then we require O(nα−1/2)O(n^{\alpha-1/2}) proposed switches before we have simulated a total time interval of length O(n−1/2)O(n^{-1/2}), so that, with a complexity of O(n)O(n) per proposed switching time, the Zig-Zag algorithm has total computational complexity O(nα+1/2)O(n^{\alpha+1/2}). So, for example, with global bounds we have that the computational bound is O(n)O(n) (as each term in the log density is O(1)O(1)), and hence ZZ will have total computational complexity of O(n3/2)O(n^{3/2}).

Consider Algorithm 2 in the one-dimensional case, with the second derivative of Ψ\Psi bounded from above by Q>0Q>0. We have Q=O(n)Q=O(n) as Ψ′′\Psi^{\prime\prime} is the sum of nn terms of O(1)O(1). The value of bb is kept fixed at the value b=Q=O(n)b=Q=O(n). Next aa is given initially as

and increased by bτb\tau until a switch happens and aa is reset to θΨ′(ξ)\theta\Psi^{\prime}(\xi). Because of the initial value for aa, switches will occur at rate O(n1/2)O(n^{1/2}) so that τ\tau will be O(n−1/2)O(n^{-1/2}), and the value of aa will remain O(n1/2)O(n^{1/2}). Hence the magnitude of the computational bound M(t)=(a+bt)+M(t)=(a+bt)^{+} is O(n1/2)O(n^{1/2}).

2 Scaling of Zig-Zag with Control Variates (ZZ-CV)

Now we will study the limiting behaviour as n→∞n\rightarrow\infty of ZZ-CV introduced in Section 4.3. In determining the computational bounds we take p=2p=2 for simplicity, e.g. in (12). Also for simplicity assume that ξ↦∂ξilog⁡f(xj∣ξ)\xi\mapsto\partial_{\xi_{i}}\log f(x^{j}\mid\xi) has Lipschitz constant kik_{i} (independent of j=1,…,nj=1,\dots,n) and write Ci=nkiC_{i}=nk_{i}, so that (12) is satisfied. In practice there may be a logarithmic increase with nn in the Lipschitz constants kik_{i} as we have to take a global bound in nn. For the present discussion we ignore such logarithmic factors. We assume reference points ξ⋆\xi^{\star} for growing nn are determined in such a way that ∥ξ⋆−ξ^∥2\|\xi^{\star}-\widehat{\xi}\|_{2} is O(n−1/2)O(n^{-1/2}). For definiteness, suppose there exists a dd-dimensional random variable ZZ such that n1/2(ξ⋆−ξ^)→Zn^{1/2}(\xi^{\star}-\widehat{\xi})\rightarrow Z in distribution, with the randomness in ZZ independent of (xj)j=1∞(x^{j})_{j=1}^{\infty}.

We can look at ZZ-CV with respect to the scaled coordinate ϕ\phi as n→∞n\rightarrow\infty. Denote the reference point for the rescaled parameter as ϕ⋆:=n(ξ⋆−ξ^)\phi^{\star}:=\sqrt{n}(\xi^{\star}-\widehat{\xi}).

The essential quantities to consider are the switching rate estimators EijE_{i}^{j}. We estimate

We find that ∣Eij(ξ)∣=O(n1/2)|E_{i}^{j}(\xi)|=O(n^{1/2}) under the stationary distribution.

By slowing down the Zig-Zag process in ϕ\phi space by n\sqrt{n}, the continuous time process generated by ZZ-CV will approach a limiting Zig-Zag process with a certain switching rate of O(1)O(1). In general this switching rate will depend on the way that ξ⋆\xi^{\star} is obtained. To simplify the exposition, in the following computation we assume ξ⋆=ξ^\xi^{\star}=\widehat{\xi}. Rescaling by n−1/2n^{-1/2}, and developing a Taylor approximation around ξ^\widehat{\xi},

By Theorem 4.1, the rescaled effective switching rate for ZZ-CV is given by

Just as with ZZ, the rescaled Zig-Zag process underlying ZZ-CV converges to a limiting Zig-Zag process with switching rate λ~i(ϕ,θ)\widetilde{\lambda}_{i}(\phi,\theta). Since the computational bounds of ZZ-CV are O(n1/2)O(n^{1/2}), a completely analogous reasoning to the one for ZZ algorithm above (Section 5.1) leads to the conclusion that O(1)O(1) proposed switches are required to obtain an independent sample. However, in contrast with the ZZ-algorithm, the ZZ-CV algorithm is designed in such a way that the computational cost per proposed switch is O(1)O(1).

We conclude that the computational complexity of the ZZ-CV algorithm is O(1)O(1) per independent sample. This provides a factor nn increase in efficiency over standard MCMC algorithms, resulting in an asymptotically unbiased algorithm for which the computational cost of obtaining an independent sample does not depend on the size of the data.

3 Remarks

The arguments above assume we are at stationarity – and how quickly the two algorithms converge is not immediately clear. Note however that for sub-sampling Zig-Zag it is possible to choose the reference point ξ⋆\xi^{\star} as starting point, thus avoiding much of the issues about convergence.

In some sense, the good computational scaling of ZZ-CV is leveraging the asymptotic normality of the posterior, but in such a way that ZZ-CV always samples from the true posterior. Thus when the posterior is close to Gaussian it will be quick; when it is far from Gaussian it may well be slower but will still be “correct”. This is fundamentally different from other algorithms (Neiswanger, Wang and Xing 2013; Scott et al. 2016; Bardenet, Doucet and Holmes 2015, e.g.) that utilise the asymptotic normality in terms of justifying their approximation to the posterior. Such algorithms are accurate if the posterior is close to Gaussian, but may be inaccurate otherwise, and it is often impossible to quantify the size of the approximation in practice.

Examples and experiments

There are essentially two different ways of using the Zig-Zag skeleton points which we obtain by using e.g. Algorithms 1, 2, or 3.

We can also estimate posterior quantiles by using the quantiles of the sample Ξ1,…,Ξm\Xi_{1},\ldots,\Xi_{m}, as with standard MCMC output. An issue with this approach is that we have to decide on the number, mm, of samples we wish to use. Whilst the more samples we use the greater the accuracy of our approximation to π(f)\pi(f), this comes at an increased computational and storage cost. The trade-off in choosing an appropriate value for mm is equivalent to the choice of how much to thin output from a standard MCMC algorithm.

It is important that one does not make the mistake of using the switching points of the Zig-Zag process as samples, as these points are not distributed according to π\pi. In particular, the switching points are biased towards the tails of the target distribution.

An alternative approach is intrinsically related to the continuous time and piecewise linear nature of the Zig-Zag trajectories. This approach consists of continuous time integration of the Zig-Zag process. By the continuous time ergodic theorem, for ff as above, π(f)\pi(f) can be estimated as

Since the output of the Zig-Zag algorithms consists of a finite number of skeleton points (Ti,Ξi,Θi)i=0k(T^{i},\Xi^{i},\Theta^{i})_{i=0}^{k}, we can express this as

2 Beating one ESS per epoch

We use the term epoch as a unit of computational cost, corresponding to the number of iterations required to evaluate the complete gradient of log⁡π\log\pi. This means that for the basic Zig-Zag algorithm (without sub-sampling), an epoch consists of exactly one iteration, and for the sub-sampled variants of the Zig-Zag algorithm, an epoch consists of nn iterations. The CPU running times per epoch of the various algorithms we consider are equal up to a constant factor. To assess the scaling of various algorithms, we use ESS per epoch. The notion of ESS is discussed in the supplementary material (Bierkens, Fearnhead and Roberts 2017, Section 2). Consider any classical MCMC algorithm based upon the Metropolis-Hastings acceptance rule. Since every iteration requires an evaluation of the full density function to compute the acceptance probability, we have that the ESS per epoch for such an algorithm is bounded from above by one. Similar observations apply to all other known MCMC algorithms capable of sampling asymptotically from the exact target distribution.

There do exist several conceptual innovations based on the idea of sub-sampling, which have some theoretical potential to overcome the fundamental limitation of one ESS per epoch sketched above.

The Pseudo-Marginal Method (PMM, Andrieu and Roberts 2009) is based upon using a positive unbiased estimator for a possibly unnormalized density. Obtaining an unbiased estimator of a product is much more difficult than obtaining one for a sum. Furthermore, it has been shown to be impossible to construct an estimator that is guaranteed to be positive without other information about the product, such as a bound on the terms in the product (Jacob and Thiery 2015). Therefore the PMM does not apply in a straightforward way to vanilla MCMC in Bayesian inference.

In the supplementary material (Bierkens, Fearnhead and Roberts 2017, Section 3) we analyse the scaling of Stochastic Gradient Langevin Dynamics (SGLD, Welling and Teh 2011) in an analogous fashion to the analysis of ZZ and ZZ-CV in Section 5. From this analysis we conclude that it is in general not possible to implement SGLD in such a way that the ESSpE has a larger order of magnitude than O(1)O(1). We compare SGLD to Zig-Zag in experiments of Sections 6.3 and 6.5.

3 Mean of a Gaussian distribution

Consider the illustrative problem of estimating the mean of a Gaussian distribution. This problem has the advantage that it allows for an analytical solution which can be compared with the numerical solutions obtained by Zig-Zag Sampling and other methods. Conditional on a one-dimensional parameter ξ\xi, the data is assumed to be i.i.d. from N(ξ,σ2)N(\xi,\sigma^{2}). Furthermore a N(0,1/ρ2)N(0,1/\rho^{2}) prior on ξ\xi is specified. Data are generated from the true distribution N(ξ0,σ2)N(\xi_{0},\sigma^{2}) for some fixed ξ0\xi_{0}. For a detailed description of the experiment and computational bounds, see Section 4 of the supplementary material.

Results for this experiment are displayed in Figure 2. The MSE for the second moment using SGLD does not decrease beyond a fixed value, indicating the presence of bias in SGLD. This bias does not appear in the different versions of Zig-Zag sampling, agreeing with the theoretical result that ergodic averages over Zig-Zag trajectories are consistent. Furthermore we see a significant relative increase in efficiency for ZZ-(so)CV over basic ZZ when the number of observations is increased, agreeing with the scaling results of Section 5. A poor choice of reference point (as in ZZ-soCV) is seen to have only a small effect on the efficiency.

4 Logistic regression

Combined with a flat prior distribution, this induces a posterior distribution ξ\xi given observations of (xj,yj)(x^{j},y^{j}) for j=1,…,nj=1,\dots,n; see the supplementary material for implementational details (Bierkens, Fearnhead and Roberts 2017, Section 5).

The results of this experiment are shown in Figure 3. In both the plots of ESS per epoch (see (a) and (c)), the best linear fit for ZZ-CV has slope approximately 0.95, which is in close agreement with the scaling analysis of Section 5. The other algorithms have roughly a horizontal slope, corresponding to a linear scaling with the size of the data. We conclude that, among the algorithms tested, ZZ-CV is the only algorithm for which the ESS per CPU second is approximately constant as a function of the size of the data (see Figure 3, (b) and (d)). Furthermore ZZ-CV obtains an ESSpE which is roughly linearly increasing with the number of observations nn (see Figure 3,(a) and (c)). whereas the other versions of the Zig-Zag algorithms, and MALA, have an ESSpE which is approximately constant with respect to nn. These statements apply regardless of the dimensionality of the problem.

5 A non-identifiable logistic regression example with unbounded Hessian

In Figure 4 we compare trace plots for the Zig-Zag algorithms (ZZ, ZZ-CV) to trace plots for Stochastic Gradient Langevin Dynamics (SGLD) and the Consensus Algorithm Scott et al. 2016. SGLD and Consensus are seen to be strongly biased, whereas ZZ and ZZ-CV target the correct distribution. However this comes at a cost: ZZ-CV loses much of its efficiency in this situation (due to the combination of lack of posterior contraction and unbounded Hessian); in particular it is not super-efficient. The use of multiple reference points may alleviate this problem, see also the discussion in Section 7.

Discussion

We have introduced the multi-dimensional Zig-Zag process and shown that it can be used as an alternative to standard MCMC algorithms. The advantages of the Zig-Zag process are that it is a non-reversible process, and thus has the potential to mix better than standard reversible MCMC algorithms, and that we can use sub-sampling ideas when simulating the process and still be guaranteed to sample from the true target distribution of interest. We have shown that it is possible to implement sub-sampling with control-variates in a way that we can have super-efficient sampling from a posterior: the cost per effective sample size is sub-linear in the number of data points. We believe the latter aspect will be particularly useful for applications where the computational cost of calculating the likelihood for a single data point is high.

As such, the Zig-Zag process holds substantial promise. However, being a completely new method, there are still substantial challenges in implementation which will need to be overcome for Zig-Zag to reach the levels of popularity of standard discrete-time MCMC. The key challenges to implementing the Zig-Zag efficiently are

to simulate from the relevant time-inhomogeneous Poisson process; and

in order to realise the advantages of Zig-Zag for large datasets, reasonable centering points need to be found before commencing the MCMC algorithm itself.

For the first of these challenges, we have shown how this can be achieved through bounding the rate of the Poisson process, but the overall efficiency of the simulation algorithm then depends on how tight these bounds are. In Subsection 3.1 we describe efficient ways to carry this out. Moreover, as pointed out by a reviewer, there is a substantial literature on simulating stochastic processes that involve simulating such time-inhomogeneous Poisson processes Gibson and Bruck 2000; Anderson 2007. Ideas from this literature could be leveraged both to extend the class of models for which we can simulate the Zig-Zag process, and also to make implementation of simulation algorithms more efficient.

The second challenge applies when using the ZZ-CV algorithm to obtain super-efficiency for big data as discussed in Subsection 4.3. Although in our experience finding appropriate centering points is rarely a serious problem, it is difficult to give a prescriptive recipe for this step.

On the face of it, these challenges may limit the practical applicability of Zig-Zag, at least in the short term. With that in mind, we have released an R/Rcpp package for logistic regression, as well as the code which reproduces the experiments of Section 6 Bierkens 2017.

In addition, while Zig-Zag is an exact approximate simulation method, there are various short-cuts to speed it up at the expense of the introduction of an approximation. For instance, there are already ideas of approximately simulating the continuous-time dynamics, through approximate bounds on the Poisson rate Pakman et al. 2016. These ideas can lead to efficient simulation of the Zig-Zag process for a wide class of models, albeit with the loss of exactness. Understanding the errors introduced by such an approach is an open area.

The most exciting aspect of the Zig-Zag process is the super-efficiency we observe when using sub-sampling with control variates. Already this idea has been adapted and shown to apply to other recent continuous-time MCMC algorithms Fearnhead et al. 2018; Pakman et al. 2016. We have shown in Subsection 6.5 that Zig-Zag can be applied effectively within highly non-Gaussian examples where rival approximate methods such as SGLD and the Consensus Algorithm are seriously biased. So there is no intrinsic reason to expect Zig-Zag to rely on the target distribution being close to Gaussian, although posterior contraction and the ability to find tight Poisson process rate bounds play important roles as we saw in our examples. There is much to learn about how the efficiency of Zig-Zag depends on the statistical properties of the posterior distribution. However, unlike its approximate competitors, Zig-Zag will still remain an exact approximate method whatever the structure of the target distribution.

In truly ‘big data’ settings, in principle we still need to process all the data once, although a suitable reference point can be determined using a subset of the data, we do need to evaluate the full gradient of the log density once at this reference point, and this computation is O(n)O(n). This operation however is much easier to parallelize than MCMC is, and after this approximately independent samples can be obtained at a cost of O(1)O(1) each. Thus if we wish to obtain kk approximately independent samples, the computational efficiency of ZZ-CV is O(k+n)O(k+n) while the complexity of traditional MCMC algorithms is O(kn)O(kn). This is confirmed by the experiment in Section 6.4.

The idea for control variates we present in this paper is just one, possibly the simplest, implementation of this idea. There are natural extensions to deal with e.g. multi-modal posteriors or situations where we do not have posterior concentration for all parameters. The simplest of these involve using multiple reference points and monitoring the computational bound we get within the CV-ZZ algorithm and switching to a different algorithm when we stray so far from a reference point that this bound becomes too large. More sophisticated approaches include using the ideas from Dubey et al. 2016, where we introduce a reference point for each data point and update the reference points for data within the subsample at each iteration of the algorithm. This would lead to the estimate of the gradient that we center our control variate estimator around to depend on the recent history of the Zig-Zag process, and thus could be accurate even if we explore multiple modes or the tails of the target distribution.

The authors are grateful for helpful comments from referees, the editor and the associate editor which have improved the paper. Furthermore the authors acknowledge Matthew Moores (University of Warwick) for helpful advice on implementing the Zig-Zag algorithms as an R package using Rcpp. All authors acknowledge the support of EPSRC under the ilike grant: EP/K014463/1.

Supplementary Material

Supplement: Supplement to “The Zig-Zag Process and Super-Efficient Sampling for Bayesian Analysis of Big Data” (doi: COMPLETED BY THE TYPESETTER; .pdf). Mathematics of the Zig-Zag process, scaling of SGLD, details on the experiments including how to obtain computational bounds.

References