arXiv:1601.01490v3 [physics.soc-ph] 19 Feb 2020 essi ersne samxueo oso rcse ihdiffer with processes Poisson of fac mixture the a of as use represented makes is algorithm cesses The r transform. for Laplace algorithm the Gillespie of innovative basis an h propose a we at study, but present times, inter-event the of distributions long-tailed non-Poisson for of work case or the rate, event the of courses time for tions inter-eve distributed exponentially a (i.e., algorithm processes Gillespie Poisson assume The distributions. long-tailed obey th Empirically, phenomena networks. ous social on or processes formation processes opinion queuing and of networks occurrences, earthquake syst including or events discrete of sequences interacting as simulat modelled for methods exact statistically provides algorithm Gillespie The Abstract 3 2 eateto ulcHat cecs aoisaInstitut Karolinska Sciences, Health Public of Department eateto ahmtc n ay,Uiested Namur, Universit´e de naXys, and of Department 1 ilsi loih o o-akva non-Markovian for algorithm Gillespie A eateto niern ahmtc,Uiest fBris of University Mathematics, Engineering of Department ∗ orsodn uhr([email protected]) author Corresponding ak Masuda Naoki eray2,2020 20, February processes 1 , ∗ 1 n usE .Rocha C. E. Luis and a eea rcse,including processes, renewal ian pkn ern,adepidemic and neurons, spiking ttms,uepriua func- particular use times), nt n vn ae.Temethod The rates. event ent m fbohmclreactions biochemical of ems g opttoa ot In cost. computational igh htacaso on pro- point of class a that t ne-vn ie fvari- of times inter-event e nwlpoesso the on processes enewal n tcatcdynamics stochastic ing 2 disvrat either variants its nd t tchl,Sweden. Stockholm, et, , 3 o,Bitl UK. Bristol, tol, au,Belgium. Namur, is applicable to multivariate renewal processes whose survival function of inter-event times is completely monotone. It is an exact algorithm and works faster than a recently proposed for general renewal processes, which is exact only in the limit of infinitely many processes. We also propose a method to generate sequences of event times with a tunable amount of positive correlation between inter-event times. We demonstrate our algorithm with exact of epidemic processes on networks, finding that a realistic amount of positive correlation in inter-event times only slightly affects the epidemic dynamics.

1 Introduction

Various complex are driven by interactions between subsystems via time-stamped dis- crete events. For example, in chemical systems, a chemical reaction event changes the number of reagents of particular types in a discrete manner. Stochastic point processes, in particular Poisson processes assuming that events occur independently and at a constant rate over time, are a central tool for emulating the dynamics of chemical systems [1]. They are also useful in simulating epidemic processes in a population [2] and many other systems.

Consider an event-driven in which events are generated by Poisson processes running in parallel. In chemical reaction systems, each Poisson process (possibly with different rates for each process) is attached to one reaction. In epidemic processes taking place on human or animal contact networks (i.e., graphs), each Poisson process is assigned to an individual or a link, which may potentially transmit the infection. The event rate of some of the Poisson processes may change with the occurrence of a reaction or infection within the entire system. The simplest method is to discretise time and then judge whether or not an event occurs in each time window, for individual processes. This widely used method is suboptimal because the size of the time window must be sufficiently small to obtain high accuracy, which is computationally expensive [3]. The Gillespie algorithm is an efficient and statistically exact

2 algorithm for multivariate Poisson processes [4–6]. The Gillespie algorithm, or, in particular, the direct method of Gillespie [5,6], exploits the fact that a superposition of independent Poisson processes is a single Poisson process whose event rate is the sum of those of the constituent

Poisson processes. Using this mathematical property, only a single Poisson process needs to be emulated in the Gillespie algorithm. However, for various real-world systems in which multivariate point processes have been applied (both with and without network structure), event sequences are clearly non-Poissonian.

In particular, inter-event times typically obey long-tailed distributions, which are inconsistent with the exponential (i.e., short-tailed) distribution that Poisson processes produce. Examples of long-tailed distributions of inter-event times include earthquake occurrences [7, 8], firing of neurons [9, 10], social networks and the Internet [11–14], financial transactions [15, 16], and crimes [17,18]. Therefore, multivariate point processes that are not necessarily Poissonian have been used in these applications, e.g., triggered seismicity [19, 20], networks of spiking neurons [21, 22], epidemic processes [14, 23], opinion formation models [24, 25], finance [26, 27], and criminology [17,28]. These applications call for numerical methods to efficiently and accurately simulate interacting and non-Markovian point processes. A reasonable description of event sequences in these phenomena requires, at the very least, renewal processes, in which inter-event times are independently generated from a given distri- bution [29, 30]. Along these lines, one numerical approach is to use the modified next reaction method [31], which improves on both the so-called Gillespie’s first reaction method [5] and the next reaction method [32]. The basic idea behind these methods is to draw the next event time for all processes from predetermined distributions, select the process that has generated the minimum waiting time to the next event, execute the event, and repeat. However, for non-Poissonian renewal processes, it is generally difficult to numerically solve the equations that determine the next event time although these methods call for the generation of only half

3 as many random numbers in comparison to the Gillespie algorithm [3]. In addition, we can easily halve the number of random variates required in the Gillespie algorithm, such that the next reaction method and the Gillespie algorithm demand the same number of random variates

(Appendix A). In what follows, we restrict ourselves to the Gillespie algorithm and its variants. Motivated by applications to chemical reactions, many extensions of the Gillespie algorithm in the case of non-Poissonian processes assume that the dynamical change in the event rate is exogenously driven in particular functional forms [33, 34]. These extensions are not applicable for general renewal processes, because the event rate of a constituent process is a function of the time since the last event of the process, which depends on that process. In other words, we cannot assume a common exogenous driver. Bogu˜n´aand colleagues extended the Gillespie algorithm to be applicable for general renewal processes [35] (also see [3] for further developments). However, the algorithm has practical limitations. First, it is not accurate when the number of ongoing renewal processes is small [35]. This can result in a considerable amount of approximation error in the beginning or final stages of the dynamics of epidemic or opinion formation models, for example, in which only a small number of processes is active, even in a large population [3]. Second, it is necessary to recalculate the instantaneous event rate of each process following the occurrence of every event in the entire population, a procedure that can be computationally expensive. In the present study, we propose an innovative Gillespie algorithm, the Laplace Gillespie algorithm, which is applicable to non-Poissonian renewal processes. It exploits the mathemati- cal properties of the Laplace transform, is accurate for an arbitrary number of ongoing renewal processes, and runs faster than the previous algorithm [35]. This article is organised as follows. In section 2, we review the original Gillespie algorithm for Poisson processes. In section 3, we review the previous extension of the Gillespie algorithm to general renewal processes [35]. In section 4, we introduce the Laplace Gillespie algorithm, together with theoretical underpin-

4 nings and examples. In section 5, we numerically compare the previous algorithm [35] and the Laplace Gillespie algorithm. In section 6, we introduce a method to generate event sequences with positive correlation in inter-event times, as is typically observed in human behaviour and natural phenomena [13]. In section 7, we demonstrate our methods by performing exact sim- ulations of an epidemic process in which inter-event times follow a power-law distribution. In section 8, we discuss the results, including limitations of the proposed algorithm. The codes used in our numerical simulations are available in the Supplementary Materials.

2 Gillespie algorithm

The original Gillespie algorithm [4–6] assumes N independent Poisson processes with a rate of λi (1 i N) running in parallel. Because of the independence of the different Poisson processes, ≤ ≤ N the superposition of the N processes is a Poisson process with rate i=1 λi. Therefore, we first draw ∆t, an increment in time to the next event of the superposedP Poisson process, from the given by

N N −(Pi=1 λi)∆t φ(∆t)= λi e . (1) i=1 ! X Because the survival function (i.e., the probability that a is larger than a certain

∞ − N λ ∆t N value) of φ(∆t) is given by φ(t′)dt′ = e (Pi=1 i) , we obtain ∆t = log u λ , ∆t − i=1 i where u is a random variateR drawn from the uniform density on the interval [0, 1]. P Then, we determine the process i that has produced the event with probability

λi Πi = N . (2) i=1 λi Finally, we advance the time by ∆t and repeatP the procedure. Following the occurrence of an event, any λi is permitted to change.

5 3 Non-Markovian Gillespie algorithm

Now consider N renewal processes running in parallel, and denote by ψi(τ) the probability den- sity function of inter-event times for the ith process (1 i N). If the process is Poissonian, ≤ ≤ −λiτ we obtain ψi(τ)= λie . For such a population of general renewal processes, Bogu˜n´a and col- leagues proposed an extension of the Gillespie algorithm, which they called the non-Markovian Gillespie algorithm (nMGA) [35]. To begin with, we explain their exact Gillespie algorithm for general renewal processes, which is the basis of the nMGA. A short derivation of the exact Gillespie algorithm is given in

Appendix B. We denote by ti the time elapsed since the last event of the ith process, and by

∞ ′ ′ Ψi(ti)= ψi(τ )dτ (3) Zti the survival function of the ith process (i.e., the probability that the inter-event time is larger than ti). We also set N Ψ (t + ∆t) Φ(∆t t )= j j , (4) |{ j} Ψ (t ) j=1 j j Y which is in fact equal to the probability that no process generates an event for time ∆t (see Appendix B). The exact Gillespie algorithm for general renewal processes is given as follows:

1. Initialise t (1 j N) for all j (for example, t = 0). j ≤ ≤ j

2. Draw the time until the next event, ∆t, by solving Φ(∆t t )= u, where u is a random |{ j } variate uniformly distributed over [0, 1].

3. Select the process i that has generated the event with probability

λi(ti + ∆t) Πi N , (5) ≡ j=1 λj(tj + ∆t)

where λi(ti + ∆t) ψi(ti + ∆t)/Ψi(ti +P ∆t) is equal to the instantaneous rate of the ith ≡ process.

6 4. Update the time since the last event, t , to t + ∆t (j = i) and set t = 0. j j 6 i

5. Repeat steps 2–4.

Although this algorithm is statistically exact, step 2 can be time-consuming [3, 35]. To improve performance, Bogu˜n´aand colleagues introduced the nMGA. The nMGA is an approx- imation to the aforementioned algorithm and is exact as N . When ∆t is small, as is the →∞ case when N is large, Eq. (4) is approximated as

N Ψ (t ) Φ(∆t t ) = exp ln j j |{ j} − Ψ (t + ∆t) " j=1 j j # X N Ψ (t ) = exp ln j j − Ψ (t ) ψ (t )∆t + O(∆t2) " j=1 j j j j # X − N exp ∆t λ (t ) . (6) ≈ − j j " j=1 !# X With this approximation, the time until the next event is determined by Φ(∆t t ) |{ j} ≈ exp ∆t N λ (t ) = u, i.e., ∆t = ln u N λ (t ) . The process that generates − j=1 j j − j=1 j j h  i   the event isP determined by setting ∆t = 0 in Eq. (5).P For a Poisson process, we set λi(ti)= λi to recover the original Gillespie algorithm (cf. Eqs. (1) and (2)).

4 Laplace Gillespie algorithm

4.1 Algorithm

In the nMGA, we update the instantaneous event rates for all the processes λ (t ) (1 j N) j j ≤ ≤ and their sum following the occurrence of each event. This is because t (1 j N) is updated j ≤ ≤ following an event. This procedure is time-consuming when N is large; we have to update λj(tj) even if the probability density of the inter-event times for the jth process is not perturbed by an event that has occurred elsewhere.

7 To construct an efficient Gillespie algorithm for non-Markovian point processes, we start by considering the following renewal process, called the event-modulated Poisson process. When an event occurs, we first draw the rate of the Poisson process, denoted by λ, according to a

fixed probability density function p(λ). Then, we draw the time until the next event according to the Poisson process with rate λ. Upon the occurrence of the next event, we renew the rate λ by redrawing it from p(λ). We then repeat these steps. The event-modulated Poisson process is a mixture of Poisson processes of different rates. It is, in general, a non-Poissonian renewal process and is slightly different from a mixed Poisson process, in which a single rate is initially drawn from a random ensemble and used throughout a realisation [36, 37]. It is also different from a doubly stochastic Poisson process (also known as a Cox process), in which the rate of the Poisson process is a stochastic process [36–38], or its subclass called the Markov-modulated Poisson process, in which the event rate switches in time according to a Markov process [39]. In these processes, the dynamics of the event rate are independent of the occurrence of events. In contrast, for event-modulated Poisson processes, the event rate changes upon the occurrence of events.

An event-modulated Poisson process is a Poisson process when conditioned on the current value of λ. Therefore, when we simulate N event-modulated Poisson processes, they are inde- pendent of each other and of the past event sequences if we are given the instantaneous rate of the ith process, denoted by λ for all i (1 i N). This property enables us to construct i ≤ ≤ a Gillespie algorithm. By engineering p(λ), we can emulate a range of renewal processes with different distributions of inter-event times. The new Gillespie algorithm, which we call the Laplace Gillespie algorithm (the reason for this name will be made clear in section 4.2, where we discuss the algorithm’s theoretical basis in the Laplace transform), is defined as the Gillespie algorithm for event-modulated Poisson processes. We denote the density of the event rate for the ith process by pi(λi). The Laplace Gillespie algorithm proceeds as follows:

8 1. Initialise each of the N processes by drawing the rate λ (1 i N) according to its i ≤ ≤

density function pi(λi).

2. Draw the time until the next event ∆t = ln u/ N λ , where u is a random variate − j=1 j uniformly distributed over [0, 1]. P

N 3. Select the process i that has generated the event with probability λi/ j=1 λj. P 4. Draw a new rate λ according to p (λ ). If there are processes j (1 j N) for which the i i i ≤ ≤ statistics of inter-event times have changed following the occurrence of the event generated

in steps 2 and 3 (e.g., a decrease in the rate of being infected owing to the recovery of an

infected neighbour), modify pj(λj) accordingly and draw a new rate λj from the modified

pj(λj). The event rates of the remaining processes remain unchanged.

5. Repeat steps 2–4.

4.2 Theory

An event-modulated Poisson process is a renewal process. The renewal process is fully charac- terised by the probability density of inter-event times, ψ(τ). For an event-modulated Poisson process with probability density of the event rate p(λ), we obtain

∞ ψ(τ)= p(λ)λe−λτ dλ. (7) Z0 Integration of both sides of Eq. (7) yields the survival function of the inter-event times as follows: ∞ ∞ Ψ(τ)= ψ(τ ′)dτ ′ = p(λ)e−λτ dλ. (8) Zτ Z0 Equation (8) indicates that Ψ(τ) is the Laplace transform of p(λ). Therefore, the necessary and sufficient condition for a renewal process to be simulated by the Laplace Gillespie algorithm is

9 that Ψ(τ) is the Laplace transform of a probability density function of a random variable taking nonnegative values. Although this statement can be made more rigorous if we replace p(λ)dλ by the probability distribution function, we will use the probability density representation for simplicity. A necessary and sufficient condition for the existence of p(λ) is that Ψ(τ) is completely monotone and Ψ(0) = 1 [30]. The complete monotonicity is defined by dnΨ(τ) ( 1)n 0 (τ 0, n =0, 1,...). (9) − dτ n ≥ ≥ Condition Ψ(0) = 1 is satisfied by any survival function. With n = 0, Eq. (9) reads Ψ(τ) 0, ≥ which all survival functions satisfy. With n = 1, Eq. (9) reads ψ(τ) 0, which is also always ≥ satisfied. However, Eq. (9) with n 2 imposes nontrivial conditions. ≥ 4.3 Examples

In this section, we give examples of distributions of inter-event times ψ(τ) for which the Laplace Gillespie algorithm can be used. These examples are summarised in Table 1.

Exponential distribution •

−λ0τ A Poisson process with rate λ0, i.e., ψ(τ) = λ0e , is trivially generated by p(λ) = δ(λ λ ), where δ is the delta function. − 0 Power-law distribution derived from a gamma distribution of λ • Consider the case in which p(λ) is the gamma distribution given by λα−1e−λ/κ p(λ)= , (10) Γ(α)κα where Γ(α) is the , α is the shape parameter, and κ is the scale parameter. By combining Eqs. (8) and (10), we obtain 1 Ψ(τ)= . (11) (1 + κτ)α

10 The probability density of inter-event times is given by the following power-law distribu- tion: κα ψ(τ)= . (12) (1 + κτ)α+1 When α = 1, p(λ) is the exponential distribution and ψ(τ) τ −2 [40]. The same mathe- ∝ matical relationship connecting the gamma distribution and a power-law distribution has been used in superstatistics in statistical mechanics [41] and in a reinforcement learning model for generating discount rates that decay with time according to a power law [42].

Power-law distribution with an exponential tail derived from a gamma distribution of λ • Consider a shifted gamma distribution [37] given by

α−1 −(λ−λ )/κ (λ−λ0) e 0 (λ λ ), p(λ)= Γ(α) ≥ 0 (13) (0 (0 <λ<λ0),

where λ0 is a constant. By combining Eqs. (8) and (13), we obtain

e−λ0τ Ψ(τ)= . (14) (1 + κτ)α

By differentiating Eq. (14), we obtain a power-law distribution with an exponential tail

given by e−λ0τ κα ψ(τ)= λ + . (15) (1 + κτ)α 0 1+ κτ   Power-law distribution derived from a uniform distribution of λ •

Assume that p(λ) is a uniform density on [λmin,λmax] [40]. We obtain

e−λminτ e−λmaxτ Ψ(τ)= − (16) τ (λ λ ) max − min and λ e−λminτ λ e−λmaxτ e−λminτ e−λmaxτ ψ(τ)= min − max + − . (17) (λ λ ) τ (λ λ ) τ 2 max − min max − min

11 Now suppose that λ λ . If λ > 0, we obtain ψ(τ) e−λminτ /τ as τ , a min ≪ max min ∝ → ∞ power-law distribution with an exponential cutoff. If λ = 0, we obtain ψ(τ) 1/τ 2 as min ∝ τ . →∞

Power-law distribution derived from a power-law distribution of λ • Consider the distribution

p(λ)=(α + 1)λα, (18)

where α> 1 and 0 λ 1 [40]. We obtain − ≤ ≤ α +1 Ψ(τ)= γ(α +1, τ), (19) τ α+1

τ α −x where γ(α +1, τ)= 0 x e dx is the incomplete gamma function, and

R α +1 ψ(τ)= γ(α +2, τ). (20) τ α+2

As τ , we obtain ψ(τ) (α + 1)Γ(α + 2)/τ α+2. →∞ ≈

Weibull distribution • The Weibull distribution is defined by

α Ψ(τ)= e−(µτ) , (21)

which yields

α ψ(τ)= αµατ α−1e−(µτ) . (22)

The Weibull distribution with α = 1 is an exponential distribution. The Weibull distri- bution has a longer and shorter tail than the exponential distribution when α < 1 and α> 1, respectively. The Weibull distribution can be expressed as the Laplace transform

12 of a p(λ) if and only if 0 <α 1 [43,44]. The distribution when α =1/2 is the so-called ≤ stable distribution of order 1/2, for which we obtain [30, 37, 43]

1 − m m 2 e 4λ p(λ)= 3 . (23) 2√πλ 2

For other values of α (i.e., 0 <α< 1/2 or 1/2 <α< 1), the explicit form of p(λ) is

complicated [43] such that the use of the Laplace Gillespie algorithm is impractical. For these α values, a mixture of a small number of exponential distributions may resemble the Weibull distribution [45], such that we may be able to use p(λ) with point masses at some discrete values of λ to approximate the Weibull distribution of inter-event times.

Gamma distribution • When inter-event times obey the gamma distribution, i.e.,

τ α−1e−τ/κ ψ(τ)= , (24) Γ(α)κα

Ψ(τ) can be expressed as the Laplace transform of a probability density function p(λ) if and only if 0 <α 1 [46, 47]. We obtain [47] ≤ 0 (0 <λ<κ−1), p(λ)= (25) 1 (λ κ−1). ( Γ(α)Γ(1−α)λ(κλ−1)α ≥ Mittag–Leffler distribution • Consider the distribution of inter-event times defined in terms of the survival function given by Ψ(τ)= E ( τ β), (26) β − where ∞ zn E (z)= (27) β Γ(1 + βn) n=0 X 13 is the so-called Mittag–Leffler function. When 0 <β< 1, Ψ(τ) is completely monotone, and we obtain [48, 49] 1 λβ−1 sin(βπ) p(λ)= . (28) π λ2β +2λβ cos(βπ)+1 When β = 1, Eqs. (26) and (27) imply that Ψ(τ) = e−λτ , yielding a Poisson process. When 0 <β< 1, Ψ(τ) is long-tailed with the asymptotics [48, 50]

sin(βπ)Γ(β) Ψ(τ) , (29) ≈ πτ β

or, equivalently, β sin(βπ)Γ(β) ψ(τ) . (30) ≈ πτ β+1 Therefore, this class of ψ(τ) produces long-tailed distributions of inter-event times with a power-law exponent lying between one and two. A special case occurs when β = 1/2,

′ in which case Ψ(τ) = e−τ 2β 1 erf(τ β) , where erf(z) (2/√π) z e−z 2 dz′ is the error − ≡ 0 function.   R

Integral of a valid survival function • The function given by

∞ Ψ(τ ′)dτ ′ ∞ Ψ(τ ′)dτ ′ Ψw(τ) τ = τ (31) ≡ ∞ Ψ(τ ′)dτ ′ τ R0 R h iψ is well-defined if and only if τ ,R i.e., the mean inter-event time with respect to den- h iψ sity ψ(τ) is finite. Assume that the renewal process generated by ψ(τ) permits use of the Laplace Gillespie algorithm. Because Ψw(τ) 0 (τ 0), dnΨw(τ)/dτ n = ≥ ≥ [dn−1Ψ(τ)/dτ n−1] / ∞ Ψ(τ ′)dτ ′ (n = 1, 2,...), and Ψ(τ) is completely monotone, it − 0 follows that Ψw(τ) is completelyR monotone. In addition, Eq. (31) implies that Ψw(0) = 1. Therefore, the renewal process with survival function Ψw(τ) can also be simulated by the Laplace Gillespie algorithm.

14 The corresponding probability density of inter-event times is given by

dΨw(τ) Ψ(τ) ψw(τ)= = . (32) − dτ τ h iψ In terms of p(λ), we obtain ∞ −λτ w 0 p(λ)e dλ ψ (τ)= ′ (33) ∞ p(λ ) ′ R 0 λ′ dλ and R ∞ p(λ) −λτ w 0 λ e dλ Ψ (τ)= ′ . (34) ∞ p(λ ) ′ R 0 λ′ dλ Therefore, in each update of the Laplace GillespieR algorithm with the density of inter- event times given by ψw(τ), the rate of the Poisson process λ should be sampled according to density pw(λ), where p(λ) w λ p (λ)= ′ . (35) ∞ p(λ ) ′ 0 λ′ dλ For example, if ψ(τ) is an exponential distribution,R then ψw(τ) is an exponential distri-

bution of the same mean. If ψ(τ) is the power-law distribution given by Eq. (12), then ψw(τ) is a power-law distribution of the same form, with α replaced by α 1. −

Product of valid survival functions •

The product of two completely monotone functions, Ψ1(τ) andΨ2(τ), is completely mono-

tone [30]. In addition, Ψ1(0)Ψ2(0) = 1 if Ψ1(0) = Ψ2(0) = 1. Therefore, the survival function Ψ(τ) Ψ (τ)Ψ (τ) admits use of the Laplace Gillespie algorithm if Ψ (τ) and ≡ 1 2 1

Ψ2(τ) do as well. The probability density of the event rate will be the convolution of

∞ −λτ p1(λ) and p2(λ), where Ψi(τ)= 0 pi(λ)e dλ (i =1, 2). R Numerical Laplace transform • Given an arbitrary p(λ), we can in principle carry out a numerical Laplace transform to derive Ψ(τ). We then obtain a valid ψ(τ) by numerically differentiating Ψ(τ).

15 4.4 Empirical distributions of inter-event times

We are often interested in informing multivariate point processes by empirical data of event se- quences. A standard numerical approach is to emulate the dynamics (e.g., epidemic processes) on top of empirical event sequences, i.e., use empirically observed events with time stamps to induce, for example, infection events [14,23]. There exists a Gillespie algorithm to run dynam- ical processes on such empirical temporal networks [3]. Another approach is to estimate ψ(τ) from empirical data and then use a variant of the Gillespie algorithm (e.g., the nMGA or the Laplace Gillespie algorithm) to simulate stochastic point processes (e.g., epidemic processes). The Laplace Gillespie algorithm requires the survival function, Ψ(τ), to be completely monotone. Under this condition, we may be able to compute the inverse Laplace transform to obtain p(λ) at a reasonable computational cost [51]. However, because it is likely that an empirical Ψ(τ) is not completely monotone, we propose two alternative methods to estimate p(λ) from empirical data. The first method is to fit a completely monotone survival function of inter-event times, such as Eq. (11), to given data. The second method is to estimate a

finite mixture of exponential distributions of different means to approximate the empirical ψ(τ) or Ψ(τ). Likelihood or other cost-function methods are available for performing this estimation [43,45,52–54]. If the empirical Ψ(τ) is completely monotone, the approximation error is guaranteed to decay inversely proportional to the number of constituent distributions [55].

For both of these methods, we should be mindful of the bias in the estimation caused by a finite time window of observation [56].

4.5 Initial conditions

When we begin to run N processes, one approach is to initially draw the inter-event time for each process from ψ(τ). This initial condition defines the so-called ordinary renewal process [29]. An alternative model, called the equilibrium renewal process, assumes that the process has

16 begun at time t = , such that the first inter-event time for each process, drawn at t = 0, −∞ uses the equilibrium distribution of waiting times to the next event, rather than ψ(τ) (i.e., the distribution of inter-event times) [29]. In fact, the equilibrium distribution of waiting times to the next event coincides with ψw(τ) given by Eq. (32) [29,30,57]. To simulate the equilibrium renewal process, we start by drawing the rates of the Poisson processes according to pw(λ) given by Eq. (35). Afterwards, we draw the event rates according to p(λ).

5 Numerical performance

In this section, we compare the performances of the nMGA and the Laplace Gillespie algorithm. We use the power-law distribution of inter-event times given by Eq. (12). Because κ only controls the scale of inter-event times, we set κ = 1 without loss of generality. To generate gamma-distributed random variates, we use a well-known algorithm [58] and adapt an open source code [59] for our purposes. We generate N/3 processes by Eq. (12) with α = 1, ⌊ ⌋ another N/3 processes with α =1.5, and another N 2 N/3 N/3 processes with α = 2. ⌊ ⌋ − ⌊ ⌋ ≈ We continue the simulation until one of the N processes generates 106 inter-event times. We employ the ordinary renewal process such that the initial inter-event time for each process is drawn from ψ(τ). The survival functions for one of the processes with α = 1, one of those with α =1.5, and one of those with α = 2 are shown by the solid curves for the nMGA and the Laplace Gillespie algorithm in Figs. 1(a) and 1(b), respectively, for N = 10. The theoretical survival function, Eq. (11), is plotted with the dashed curves. The results obtained from the Laplace Gillespie algorithm (Fig. 1(b)) are more accurate than those obtained from the nMGA. This is because the nMGA is exact only in the limit of N , whereas the Laplace Gillespie algorithm is → ∞ exact for any N. When N = 103, the nMGA is sufficiently accurate (Fig. 1(c)), as is the Laplace Gillespie algorithm (Fig. 1(d)). The results shown in Figs. 1(a) and 1(c) are consistent

17 with the numerical results obtained in Ref. [35]. The nMGA may require a lot of time in updating the instantaneous event rates for all processes every time an event occurs in one of the N processes. The Laplace Gillespie algorithm avoids this rate recalculation, whereas it might be costly to calculate the gamma variates each time an event occurs. We compare numerically the computation times for the two algorithms by varying N. The other parameters remain the same as those used in Figs. 1(a)–(d). For the Laplace Gillespie algorithm, we use a binary tree data structure to store and update λi (1 i N) to accelerate the selection of the i value with probability Π upon the occurrence ≤ ≤ i of each event [32]. In short, each λi occupies a leaf of the tree, and each non-leaf node stores the sum of its left child and its right child. This data structure is useful when only a small number of λi are changed following the occurrence of each event [32]. This is not the case for the nMGA, for which all the N instantaneous event rates must be updated upon each event. Therefore, for the nMGA, we use a simple linear search, which is computationally less expensive than updating a binary tree every time an event occurs. We use codes written in C++, compiled with a standard g++ compiler without an optimisation option on a Mac Book

Air with 1.7 GHz Intel Core i7 processor and 8GB 1600 MHz DDR3 RAM. The computation time in seconds plotted as a function of N in Fig. 1(e) indicates that the Laplace Gillespie algorithm runs substantially faster than the nMGA as N increases. Both the nMGA and the Laplace Gillespie algorithm require two uniformly distributed random variates per event, as does the standard Gillespie algorithm. In addition, for each generated event, the nMGA demands O(N) time to search for the process to fire and update the instantaneous event rates for all processes. In contrast, the Laplace Gillespie algorithm demands O(k log N) time per event on average, where k is the typical number of processes that are affected by the firing of the ith process. The search for what process to fire requires O(log N) time, given the binary tree data structure [32]. The updating of λj due to the event of the ith

18 process requires O(k) time, including the generation of k gamma-distributed random variates. The updating of the binary tree requires O(k log N) time because it consumes O(log N) time for each updated λj. Because k is usually much smaller than N in practice [14,32], the Laplace Gillespie algorithm is expected to run faster than the nMGA, which is consistent with the numerical results shown in Fig. 1(e). Additionally, the Laplace Gillespie algorithm outperforms the nMGA in the sense that the Laplace Gillespie algorithm is exact for any N, whereas the nMGA is not. On the other hand, for the Laplace Gillespie algorithm, the form of ψ(τ) is limited, whereas the nMGA allows for any ψ(τ) to be used.

6 Positively correlated sequences of inter-event times

We have considered renewal processes, i.e., stationary point processes without correlation be- tween inter-event times. However, inter-event times are positively correlated for human activity and earthquakes [13, 60]. The Laplace Gillespie algorithm provides a method for generat- ing point processes with positive correlation, without changing ψ(τ). To generate such event sequences, we redraw a new event rate for the Poisson process, λ , with probability 1 q i − (0 q < 1), when the ith process has generated an event. With probability q, we continue to ≤ use the same value of λi until the ith process generates another event. We call this algorithm the correlated Laplace Gillespie algorithm. The standard Laplace Gillespie algorithm is recov- ered when q = 0. The correlation between inter-event times grows as q increases. Although the same λi value may be used for generating consecutive inter-event times, the corresponding inter-event times are different because they are generated from a Poisson process. The compu- tation time for the correlated Laplace Gillespie algorithm decreases as q increases because the number of times that λ is redrawn is proportional to 1 q. i − In a continuous-time Markov process with a state-dependent hopping rate, the inter-event

19 time defined as the time between two consecutive hops, regardless of the state, is generally correlated across inter-event times [61]. The correlated Laplace Gillespie algorithm can be interpreted as a special case of this scenario such that the state is continuous, the process hops back to the current state with probability q, and it hops to any other state with probability proportional to (1 q) p(λ). The correlated Laplace Gillespie algorithm can be alternatively − × built on top of a finite-state [61] or an infinite-state [53] Markov process with a general transition probability between states. This variant of the correlated Laplace Gillespie algorithm is similar to a two-state cascading Poisson process in which the two states correspond to different event rates [62]. Two remarks are now in order. First, ψ(τ) is independent of the q value. This is because the stationary density of the corresponding continuous-time Markov process in the λ-space is equal to p(λ), irrespective of the q value. Of course, the distribution of τ conditioned on the previous inter-event time, τ ′, is different from ψ(τ) and depends on τ ′ in general. Second, the correlated Laplace Gillespie algorithm cannot be used to generate correlated event sequences when ψ(τ) is the exponential distribution. In this case, the event rate λ must be kept constant over time and therefore cannot be modulated in a temporally correlated manner. We measure the so-called memory coefficient [13] to quantify the amount of correlation in a sequence of inter-event times generated by the correlated Laplace Gillespie algorithm. The memory coefficient for a sequence of inter-event times, τ , τ ,...,τ , where n is the number { 1 2 n} of inter-event times, is defined by

n−1(τ m )(τ m ) M = i=1 i − 1 i+1 − 2 , (36) n−1 2 n 2 P (τi m1) (τi+1 m2) i=1 − i=2 − q where m = n−1 τ /(n 1) and Pm = n τ /(nP 1). 1 i=1 i − 2 i=2 i − For the power-lawP distribution of inter-eventP times given by Eq. (12) with κ = 1, we generate a sequence of n = 105 inter-event times and calculate M. The mean and standard deviation

20 of M, calculated on the basis of 103 sequences, are plotted for α = 1 and α = 2 in Figs. 2(a) and 2(b), respectively. For both α values, M monotonically increases with q and a range of M values between 0 and 0.4 is produced. In empirical data, M lies between 0 and 0.1 for ≈ human activity and between 0.1 and 0.25 for natural phenomena [13]. These ranges of M are produced using approximately 0 q 0.2 and 0.2 q 0.5, respectively. ≤ ≤ ≤ ≤ 7 Epidemic processes

Previous numerical efforts suggested that the dynamics of epidemic processes in well-mixed populations or networks were altered if contact events were generated by non-Poissonian renewal processes [63–66]. The nMGA and the Laplace Gillespie algorithm can be used for implementing such models of epidemic processes. To demonstrate the use of the Laplace Gillespie algorithm, we simulate a node-centric susceptible-infected-recovered (SIR) epidemic process model, which is similar to previous models [63, 67, 68]. Consider a static network composed of N nodes. At any point in time, each node assumes one of the three states: susceptible, infected, or recovered. An infected node i transmits the disease to a susceptible node j upon the activation of link (i, j). To activate links, we initially assign to each node i (1 i N) an independent and identical point process whose probability ≤ ≤ density of inter-event times is given by ψ(τ). When an event occurs at node i, we select a neighbour of i, denoted by j, with the equal probability and activate link (i, j). If either i or j is infected and the other is susceptible, the disease is transmitted such that the susceptible node becomes infected. An infected node transits to the recovered state according to a Poisson process of rate µ. A recovered node neither infects nor is infected by other nodes. The mean time to node activation, which enables infection, is given by τ = ∞ τψ(τ)dτ. h i 0 The mean time for an infected node to recover is equal to 1/µ. We define the effectiveR infection rate by λ = (1/µ)/ τ [35]. We control λ by changing µ for a given ψ(τ). This definition eff h i eff 21 is justified because multiplying τ and 1/µ by the same factor only changes the time scale of h i the dynamics. We assume an equilibrium point process, i.e., we start simulations from the equilibrium state. This is equivalent to drawing the first event time for each node from the waiting-time distribution, ψw(τ), rather than from ψ(τ), and drawing subsequent event times from ψ(τ). The population structure is assumed to be either well mixed (i.e., complete graph) or the regular random graph in which all nodes have degree five and all links are randomly formed. In both cases, we set N = 104. Each simulation starts from the same initial condition, in which a particular node, which is the same in all simulations, is infected and all the other N 1 − nodes are susceptible. We measure the number of recovered nodes at the end of the simulation normalised by N, called the final size, averaged over 104 simulations. We consider four renewal processes for node activation: the exponential distribution, corresponding to a Poisson process, and three power-law distributions given by Eq. (12) with α = 1.5, κ = 1, and q = 0, 0.2, and 0.9. The final size for the well-mixed population and the regular random graph is shown in

Figs. 3(a) and 3(b), respectively. For both population structures, and across the entire range of the effective infection rate, λeff , the final size is larger when ψ(τ) is the power-law distribution than when it is the exponential distribution. Consistent with this result, the epidemic threshold, i.e., the value of λeff at which the final size becomes positive, is smaller for the power-law distribution ψ(τ) than for the exponential distribution ψ(τ). The final size is larger with positive correlation of inter-event times (q = 0.9) than with no correlation (q = 0). Results for q = 0.2 are almost identical to those for q = 0. Because realistic values of the memory coefficient, M, for human activity are produced by 0 q 0.2 ≤ ≤ (section 6), we conclude that a realistic amount of positive correlation in inter-event times does not affect the final size.

22 8 Discussion

We have provided a generalisation of the Gillespie algorithm for non-Poissonian renewal pro- cesses, which we call the Laplace Gillespie algorithm. Our algorithm is exact for any number of processes running in parallel and is faster than the nMGA [35]. Although it is only applicable to renewal processes whose survival function is completely monotone, it applies to several renewal processes of interest. We have also proposed a method to simulate non-renewal point processes with tunable positive correlation between inter-event times. Previous studies numerically explored Poissonian explanations of long-tailed distributions of inter-event times. Examples include a non-homogeneous Poisson process whose event rate switches between two values and is also periodically modulated [62]. Another example is a self-exciting Hawkes process with an exponential memory kernel [60]. We have shown that a power-law distribution of inter-event times, Eq. (12), is generated when the rate of an event- modulated Poisson process is drawn from the gamma distribution upon the occurrence of every event. This observation provides a theoretical underpinning of the fact that non-homogeneous Poisson processes and Hawkes processes can generate long-tailed distributions of inter-event times. In other words, switching between different rates is a general mechanism to produce long-tailed distributions of inter-event times. Although the present results indicate that, in theory, we require a mixture of an infinite number of Poisson processes of different rates to produce a power-law distribution, in practice a small number of Poisson processes may be sufficient. In fact, a mixture of a small number of exponential distributions is sometimes employed to fit empirical distributions of inter-event times [43, 45, 52, 54]. We have applied the Laplace Gillespie algorithm to an epidemic model in well-mixed and networked populations. The applicability of the Laplace Gillespie algorithm, as well as of the modified next reaction method [31] and of the nMGA, extends far beyond epidemic modelling.

23 In fact, these algorithms can simulate systems of earthquakes, spiking neurons, financial , crimes, and so on (see section 1 for references). In particular, empirical data correspond- ing to these applications suggest long-tailed distributions of inter-event times (section 1), thus yielding a CV (coefficient of variation, i.e., the standard deviation divided by the mean) larger than unity, and therefore not excluding the use of the Laplace Gillespie algorithm. It is also straightforward to include births and deaths of nodes [63,69] and links [70] of contact networks, or rewiring of links [71,72], as long as these events obey renewal processes or non-renewal point processes with positive correlation, as emulated by the correlated Laplace Gillespie algorithm. The Laplace Gillespie algorithm can be employed if and only if the survival function of inter-event times is completely monotone. Some convenient conditions for and examples of survival functions that are not completely monotone are as follows:

(i) Non-monotonicity. By setting n = 2 in Eq. (9), we obtain dψ(τ)/dτ 0. Therefore, ≤ ψ(τ) must monotonically decrease with τ for the Laplace Gillespie algorithm to be applicable. This condition excludes the gamma and Weibull distributions with shape parameter α > 1, any log-, and any Pareto distribution, i.e.,

α τ0 α+1 (τ τ0), ψ(τ)= τ0 τ ≥ (37) (0  (τ < τ0), where α> 0 and τ0 > 0. (ii) CV is smaller than unity. Complete monotonicity implies that the CV of τ is larger than or equal to unity [44]. This condition again excludes the gamma and Weibull distributions with α> 1. In practice, a CV value less than unity indicates that events occur more regularly than in a Poisson process, which would yield CV = 1. Therefore, renewal processes producing relatively periodic event sequences are also excluded.

In epidemiology, evidence suggests that empirical recovery times are less dispersed than the exponential distribution, implying a CV value less than unity. Therefore, a gamma distribution

24 with scale parameter α> 1 or even a delta distribution is often alternatively employed [73,74]. These distributions cannot be simulated by our algorithm. (iii) Higher-order conditions. Even when dψ(τ)/dτ 0 and the CV is large, Ψ(τ) may not ≤ be completely monotone. For example, the one-sided Cauchy distribution defined by ψ(τ) = 1/ [π(τ 2 + 1)] yields d2ψ(τ)/dτ 2 = 2(3τ 2 1)/ [π(τ 2 + 1)3], whose sign depends on the value of − τ. Empirical evidence of online correspondences of humans suggests that, except for very small

τ values, τ obeys a power-law distribution for small τ and an exponential distribution for large τ [75]. Such a ψ(τ) monotonically decreases with τ, verifying that dψ(τ)/dτ 0. However, ≤ the sign of d2ψ(τ)/dτ 2 depends on the τ value, such that the corresponding survival function is not completely monotone.

Appendix A: Halving the number of random variates used in the Gillespie algorithm

Each step of the Gillespie algorithm usually requires two random variates, u1 and u2, uniformly distributed on [0, 1], one to draw the time increment via ∆t = log u N λ and the − 1 i=1 i other to select the process i that fires on the basis of Eq. (2). To eliminate oneP random variate, we first select i using random variate u2. Independently of whether we use a binary or a linear search, we end up identifying the unique i value that satisfies i−1 Π u < i Π . Once j=1 j ≤ 2 j=1 j i is determined, we set u (u i−1 Π )/Π , which is in factP uniformly distributedP on [0, 1]. 1 ≡ 2 − j=1 j i

Therefore, we do not have to drawPu1 using a random number generator. This mathematical trick is similar to the one employed in the next reaction methods [31, 32].

25 Appendix B: Derivation of the exact Gillespie algorithm for general renewal processes

Consider N renewal processes running in parallel. If the ith process is running in isolation, the waiting time τ until the next event is distributed according to

w ψi(ti + τ) ψi (τ ti)= , (38) | Ψi(ti) where Ψi(ti) is the survival function of the ith process given by Eq. (3). In fact, the ith process coexists with the other N 1 processes. We denote by φ(∆t, i t ) − |{ j} the probability density with which the ith process, but not the other N 1 processes, generates − the next event in the set of N processes after time ∆t, given the time since the previous event for each process, t , i.e., t ,...,t . We obtain { j} 1 N N φ(∆t, i t )= ψw(∆t t ) Ψ (∆t t ), (39) |{ j} i | i j | j 6 j=1;Yj=i where ∞ Ψ (t + ∆t) Ψ (∆t t )= ψw(τ ′ t )dτ ′ = j j (40) j | j j | j Ψ (t ) Z∆t j j is the probability that the time until the next event for the hypothetically isolated jth process is larger than ∆t, conditioned on the assumption that the last event has occurred time tj before. Using Eqs. (38) and (40), we rewrite Eq. (39) as

ψi(ti + ∆t) φ(∆t, i tj )= Φ(∆t tj ), (41) |{ } Ψi(ti + ∆t) |{ } where Φ(∆t t ) is given by Eq. (4). |{ j} Equation (4) represents the probability that no process generates an event for time ∆t. By equating this quantity to u, a random variate over the unit interval, we can determine ∆t, i.e., the time until the next event in the entire population of the N renewal processes. Equation (41)

26 implies that, once ∆t is determined, λi(ti + ∆t)= ψi(ti + ∆t)/Ψi(ti + ∆t) is the instantaneous rate of the ith process and is proportional to the probability that the ith process generates this event. Therefore, the exact Gillespie algorithm for general renewal processes is produced as given in section 3.

Acknowledgments

N.M. acknowledges the support provided through JST, CREST, and JST, ERATO, Kawarabayashi Large Graph Project. L.E.C.R. is a Charg´ede recherche of the Fonds de la Recherche Scientifique - FNRS.

References

[1] N. G. Van Kampen. Stochastic Processes in Physics and Chemistry. Elsevier, Amsterdam, The Netherlands, 3rd edition, 2007.

[2] D. J. Daley and J. Gani. Epidemic Modelling: An Introduction. Cambridge University

Press, Cambridge, 1999.

[3] C. L. Vestergaard and M. G´enois. Temporal Gillespie algorithm: Fast simulation of con- tagion processes on time-varying networks. PLOS Comput. Biol., 11:e1004579, 2015.

[4] D. G. Kendall. An artificial realization of a simple “birth-and-death” process. J. R. Stat. Soc. Ser. B, 12:116–119, 1950.

[5] D. T. Gillespie. A general method for numerically simulating the stochastic time evolution of coupled chemical reactions. J. Comput. Phys., 22:403–434, 1976.

[6] D. T. Gillespie. Exact stochastic simulation of coupled chemical reactions. J. Phys. Chem., 81:2340–2361, 1977.

27 [7] P. Bak, K. Christensen, L. Danon, and T. Scanlon. Unified scaling law for earthquakes. Phys. Rev. Lett., 88:178501, 2002.

[8] A.´ Corral. Long-term clustering, scaling, and universality in the temporal occurrence of

earthquakes. Phys. Rev. Lett., 92:108501, 2004.

[9] W. R. Softky and C. Koch. The highly irregular firing of cortical cells is inconsistent with temporal integration of random EPSPs. J. Neurosci., 13:334–350, 1993.

[10] R. Baddeley, L. F. Abbott, M. C. A. Booth, F. Sengpiel, T. Freeman, E. A. Wakeman,

and E. T. Rolls. Responses of neurons in primary and inferior temporal visual cortices to natural scenes. Proc. R. Soc. Lond. B, 264:1775–1783, 1997.

[11] A. L. Barab´asi. The origin of bursts and heavy tails in human dynamics. Nature, 435:207– 211, 2005.

[12] A. V´azquez, J. G. Oliveira, Z. Dezs¨o, K. I. Goh, I. Kondor, and A. L. Barab´asi. Modeling bursts and heavy tails in human dynamics. Phys. Rev. E, 73:036127, 2006.

[13] K. I. Goh and A. L. Barab´asi. Burstiness and memory in complex systems. Europhys.

Lett., 81:48002, 2008.

[14] P. Holme and J. Saram¨aki. Temporal networks. Phys. Rep., 519:97–125, 2012.

[15] M. Raberto, E. Scalas, and F. Mainardi. Waiting-times and returns in high-frequency financial data: An empirical study. Physica A, 314:749–755, 2002.

[16] J. Masoliver, M. Montero, and G. H. Weiss. Continuous-time random-walk model for financial distributions. Phys. Rev. E, 67:021112, 2003.

28 [17] G. O. Mohler, M. B. Short, P. J. Brantingham, F. P. Schoenberg, and G. E. Tita. Self- exciting point process modeling of crime. J. Am. Stat. Assoc., 106:100–108, 2011.

[18] S. D. Johnson, K. J. Bowers, and K. Pease. Towards the modest predictability of daily

burglary counts. Policing, 6:167–176, 2012.

[19] Y Ogata. Seismicity analysis through point-process modeling: A review. Pure Appl. Geophys., 155:471–507, 1999.

[20] A. Helmstetter and D. Sornette. Subcritical and supercritical regimes in epidemic models of earthquake aftershocks. Journal of Geophysical Research, 107:2237, 2002.

[21] W. Truccolo, U. T. Eden, M. R. Fellows, J. P. Donoghue, and E. N. Brown. A point

process framework for relating neural spiking activity to spiking history, neural ensemble, and extrinsic covariate effects. J. Neurophysiol., 93:1074–1089, 2005.

[22] V. Pernice, B. Staude, S. Cardanobile, and S. Rotter. How structure determines correla- tions in neuronal networks. PLOS Comput. Biol., 7:e1002059, 2011.

[23] N. Masuda and P. Holme. Predicting and controlling infectious disease epidemics using temporal networks. F1000Prime Reports, 5:6, 2013.

[24] J. Fern´andez-Gracia, V. M. Egu´ıluz, and M. San Miguel. Update rules and interevent

time distributions: Slow ordering versus no ordering in the voter model. Phys. Rev. E, 84:015103(R), 2011.

[25] T. Takaguchi and N. Masuda. Voter model with non-Poissonian inter-event intervals. Phys.

Rev. E, 84:036115, 2011.

[26] C. G. Bowsher. Modelling security market events in continuous time: Intensity based, multivariate point process models. J. Econom., 141:876–912, 2007.

29 [27] V. Filimonov and D. Sornette. Quantifying reflexivity in financial markets: Toward a prediction of flash crashes. Phys. Rev. E, 85:056108, 2012.

[28] M. D. Porter and G. White. Self-exciting hurdle models for terrorist activity. Ann. Appl.

Stat., 6:106–124, 2012.

[29] D. R. Cox. Renewal Theory. Methuen & Co. Ltd, Frome, UK, 1962.

[30] W. Feller. An Introduction to Probability Theory and Its Applications, Volume II, Second Edition. John Wiley & Sons, New York, 1971.

[31] D. F. Anderson. A modified next reaction method for simulating chemical systems with time dependent propensities and delays. J. Chem. Phys., 127:214107, 2007.

[32] M. A. Gibson and J. Bruck. Efficient exact stochastic simulation of chemical systems with many species and many channels. J. Phys. Chem. A, 104:1876–1889, 2000.

[33] T. Lu, D. Volfson, L. Tsimring, and J. Hasty. Cellular growth and division in the Gillespie algorithm. Syst. Biol., 1:121–128, 2004.

[34] T. Carletti and A. Filisetti. The stochastic evolution of a protocell: The Gillespie algorithm

in a dynamically varying volume. Comput. Math. Methods Med., 2012:423627, 2012.

[35] M. Bogu˜n´a, L. F. Lafuerza, R. Toral, and M. A.´ Serrano. Simulating non-Markovian stochastic processes. Phys. Rev. E, 90:042108, 2014.

[36] A. F. Karr. Point Processes and their Statistical Inference (second edition). Marcel Dekker,

Inc., New York, NY, 1991.

[37] J. Grandell. Mixed Poisson Processes. Chapman & Hall, London, 1997.

30 [38] J. F. C. Kingman. On doubly stochastic Poisson processes. Math. Proc. Camb. Phil. Soc., 60:923–930, 1964.

[39] W. Fischer and K. Meier-Hellstern. The Markov-modulated Poisson process (MMPP)

cookbook. Perf. Eval., 18:149–171, 1992.

[40] C. A. Hidalgo R. Conditions for the emergence of scaling in the inter-event time of uncor- related and seasonal systems. Physica A, 369:877–883, 2006.

[41] C. Beck and E. G. D. Cohen. Superstatistics. Physica A, 322:267–275, 2003.

[42] Z. Kurth-Nelson and A. D. Redish. Temporal-difference reinforcement learning with dis- tributed representations. PLOS ONE, 4:e7362, 2009.

[43] N. P. Jewell. Mixtures of exponential distributions. Ann. Stat., 10:479–484, 1982.

[44] N. Yannaros. Weibull renewal processes. Ann. Inst. Stat. Math., 46:641–648, 1994.

[45] T. Jin and L. S. Gonigunta. Exponential approximation to Weibull renewal with decreasing failure rate. J. Stat. Comput. Simul., 80:273–285, 2010.

[46] N. Yannaros. On Cox processes and gamma renewal processes. J. Appl. Prob., 25:423–427,

1988.

[47] L. J. Gleser. The gamma distribution as a mixture of exponential distributions. Am. Stat., 43:115–117, 1989.

[48] R. Gorenflo and F. Mainardi. Fractional calculus: Integral and differential equations of

fractional order. In A. Carpinteri and F. Mainardi, editors, Fractals and Fractional Calculus in Continuum Mechanics, pages 223–276. Springer-Verlag, Berlin, 1997.

31 [49] R. Gorenflo, A. A. Kilbas, F. Mainardi, and S. V. Rogosin. Mittag-Leffler Functions, Related Topics and Applications. Springer-Verlag, Heidelberg, 2014.

[50] N. Georgiou, I. Z. Kiss, and E. Scalas. Solvable non-Markovian dynamic network. Phys.

Rev. E, 92:042801, 2015.

[51] J. Abate and W. Whitt. The Fourier-series method for inverting transforms of probability distributions. Queue. Syst., 10:5–87, 1992.

[52] J. J. Heckman, R. Robb, and J. R. Walker. Testing the mixture of exponentials hypothesis and estimating the mixing distribution by the method of moments. J. Am. Stat. Assoc., 85:582–589, 1990.

[53] J. Kleinberg. Bursty and hierarchical structure in streams. Data Min. Knowl. Disc., 7:373–397, 2003.

[54] M. Politi and E. Scalas. Activity spectrum from waiting-time distribution. Physica A, 383:43–48, 2007.

[55] J. Q. Li and A. R. Barron. Mixture density estimation. In S. A. Solla, T. K. Leen, and K. R M¨uller, editors, Advances in Neural Information Processing Systems, volume 12, pages 279–285, Cambridge, MA, 2000. MIT Press.

[56] M. Kivel¨aand M. A. Porter. Estimating interevent time distributions from finite observa- tion periods in communication networks. Phys. Rev. E, 92:052813, 2015.

[57] N. Masuda and R. Lambiotte. A Guide to Temporal Networks. World Scientific, Singapore,

2016.

[58] G. Marsaglia and W. W. Tsang. A simple method for generating gamma variables. ACM Trans. Math. Software, 26:363–372, 2000.

32 [59] http://www.know-all.net/articles/view/56.

[60] N. Masuda, T. Takaguchi, N. Sato, and K. Yano. Self-exciting point process modeling of conversation event sequences. In P. Holme and J. Saram¨aki, editors, Temporal Networks,

pages 245–264. Springer-Verlag, Berlin, 2013.

[61] T. Schwalger and B. Lindner. Theory for serial correlations of interevent intervals. Eur. Phys. J. Spec. Topics, 187:211–221, 2010.

[62] R. D. Malmgren, D. B. Stouffer, A. E. Motter, and L. A. N. Amaral. A Poissonian explana- tion for heavy tails in e-mail communication. Proc. Natl. Acad. Sci. USA, 105:18153–18158, 2008.

[63] L. E. C. Rocha and V. D. Blondel. Bursts of vertex activation and epidemics in evolving networks. PLOS Comput. Biol., 9:e1002974, 2013.

[64] P. Van Mieghem and R. van de Bovenkamp. Non-Markovian infection spread dramatically alters the susceptible-infected-susceptible epidemic threshold in networks. Phys. Rev. Lett.,

110:108701, 2013.

[65] B. Min, K. I. Goh, and I. M. Kim. Suppression of epidemic outbreaks with heavy-tailed contact dynamics. EPL, 103:50002, 2013.

[66] D. X. Horv´ath and J. Kert´esz. Spreading dynamics on networks: The role of burstiness, topology and non-stationarity. New J. Phys., 16:073037, 2014.

[67] L. E. C. Rocha, F. Liljeros, and P. Holme. Simulated epidemics in an empirical spatiotem-

poral network of 50,185 sexual contacts. PLOS Comput. Biol., 7:e1001109, 2011.

[68] N. Perra, B. Gon¸calves, R. Pastor-Satorras, and A. Vespignani. Activity driven modeling of time varying networks. Sci. Rep., 2:469, 2012.

33 [69] S. Bansal, J. Read, B. Pourbohloul, and L. A. Meyers. The dynamic nature of contact networks in infectious disease epidemiology. J. Biol. Dyn., 4:478–489, 2010.

[70] P. Holme and F. Liljeros. Birth and death of links control disease spreading in empirical

contact networks. Sci. Rep., 4:4999, 2014.

[71] E. Volz and L. A. Meyers. Susceptible-infected-recovered epidemics in dynamic contact networks. Proc. R. Soc. B, 274:2925–2933, 2007.

[72] T. Gross and B. Blasius. Adaptive coevolutionary networks: A review. J. R. Soc. Interface,

5:259–271, 2008.

[73] A. L. Lloyd. Destabilization of epidemic models with the inclusion of realistic distributions of infectious periods. Proc. R. Soc. Lond. B, 268:985–993, 2001.

[74] H. J. Wearing, P. Rohani, and M. J. Keeling. Appropriate models for the management of

infectious diseases. PLOS Med., 2:e174, 2005.

[75] Y. Wu, C. Zhou, J. Xiao, J. Kurths, and H. J. Schellnhuber. Evidence for a bimodal distribution in human communication. Proc. Natl. Acad. Sci. USA, 107:18803–18808,

2010.

34 (a) (b) 100 100 )) numerical )) τ τ ( -1 theory ( -1 Ψ 10 Ψ 10

10-2 10-2

10-3 10-3

10-4 10-4

survival function ( 10-5 survival function ( 10-5 10-1 100 101 102 103 104 10-1 100 101 102 103 104 τ τ (c) (d) 100 100 )) )) τ τ ( -1 ( -1

Ψ 10 Ψ 10

10-2 10-2

10-3 10-3

10-4 10-4

survival function ( 10-5 survival function ( 10-5 10-1 100 101 102 103 104 10-1 100 101 102 103 104 τ τ (e) 104

103

102

101 0 nMGA 10 Laplace computation time [sec] 10-1 100 101 102 103 N

Figure 1: Comparison between the nMGA and the Laplace Gillespie algorithm. The distri- bution of inter-event times is power law (Eq. (12)) with κ = 1. Among the N processes, N/3 processes are simulated with α = 1, another N/3 processes with α =1.5, and another N⌊ 2⌋ N/3 N/3 processes with α = 2. (a)–(d)⌊ Survival⌋ function of inter-event times for one− process⌊ ⌋ with ≈ α = 1, another with α = 1.5, and another with α = 2, from the top to the bottom. (a) nMGA when N = 10. (b) Laplace Gillespie algorithm when N = 10. (c) nMGA when N = 103. (d) Laplace Gillespie algorithm when N = 103. (e) Computation time as a function of the number of processes, N. 35 (a) (b)

0.5 0.5 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1

memory coefficient 0 memory coefficient 0 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 q q (c) (d) 100 100 )) ))

τ q = 0.1 τ ( -1 q = 0.5 ( -1 Ψ 10 Ψ 10 q = 0.9 10-2 theory 10-2 10-3 10-3 10-4 10-4

survival function ( 10-5 survival function ( 10-5 10-1 100 101 102 103 104 10-1 100 101 102 103 τ τ

Figure 2: Memory coefficient, M, for the correlated Laplace Gillespie algorithm. We used the power-law distribution of inter-event times given by Eq. (12) with κ = 1. (a) α = 1. (b) α = 2. The error bar represents the mean standard deviation. (c) Survival function of a single event ± sequence (i.e., N = 1) with 106 events with α = 1 and q =0.1, 0.5, and 0.9. (d) Similar to (c) with α = 2.

36 (a) (b) 1 1

0.8 0.8

0.6 0.6

0.4 exponential 0.4 final size α=1.5, q=0 final size 0.2 α=1.5, q=0.2 0.2 α=1.5, q=0.9 0 0 0 1 2 3 4 0 1 2 3 4 effective infection rate effective infection rate

Figure 3: Final outbreak size for the SIR epidemic model. (a) Well-mixed population. (b) Regular random graph with degree of each node equal to five. We set N = 104. For the power-law density of inter-event times, we use Eq. (12) with κ = 1 and α =1.5.

37 Table 1: Distributions of inter-event times, ψ(τ), for which the Laplace Gillespie algorithm can be used. H is the Heaviside function defined by H(x)=1(x 0) and H(x)=0(x< 0). ≥ Distribution ψ(τ) Ψ(τ) condition p(λ)(λ 0) ≥ Exponential λ e−λ0τ e−λ0τ δ(λ λ ) 0 − 0 λα−1e−λ/κ κ 1 Power law Γ(α)κα (1+κτ)α+1 (1+κτ)α − − λ−λ Power law with λ0τ λ0τ α−1 − 0 e κα e (λ−λ0) e κ H(λ−λ0) α λ0 + α exponential tail (1+κτ) 1+κτ (1+κτ) Γ(α)

−  −λ τ −λ τ Power law (with e λminτ 1 e min −e max or λmin λmax uniform on [λmin,λmax] exponential tail) ∝ τ ∝ τ 2 τ(λmax−λmin) ≪

Power law α+1 γ(α +2, τ) α+1 γ(α +1, τ) α> 1 (α + 1)λα τ α+2 τ α+1 − Weibull αµατ α−1e−(µτ)α e−(µτ)α 0 <α 1 complicated ≤ − − −1 Gamma τ α 1e τ/κ complicated 0 <α 1 H(λ−κ ) Γ(α)κα ≤ Γ(α)Γ(1−α)λ(κλ−1)α β−1 Mittag–Leffler β sin(βπ)Γ(β) E ( τ β) 0 <β< 1 1 λ sin(βπ) ≈ πτ β+1 β − π λ2β +2λβ cos(βπ)+1

38