Statistical simulation

Poisson process simulator

Simulate a Poisson process with rate λ and horizon T. Visualize the sample paths, the distribution of the number of events, and the inter-arrival times.

Trajectories N(t)

📈
Click 'Simulate' to get started.
The N(t) sample paths will be shown as step functions.

    Distribution of N(T)

    📊
    Click 'Simulate' to get started.
    The histogram of N(T) will be shown against the theoretical Poisson(λT) PMF.

    Inter-arrival times

    ⏱️
    Click 'Simulate' to get started.
    The histogram of inter-arrival times will be shown against the theoretical exponential PDF.

    What is a Poisson process?

    A Poisson process with rate λ is a continuous-time stochastic process \(N(t)\) that counts the number of events that have occurred up to time \(t\). It is characterized by three fundamental properties:

    1. Independent increments: the number of events in disjoint time intervals are independent random variables. What happens in \([0,s]\) does not affect what happens in \([s,s+t]\).
    2. Stationary increments: \(N(s+t) - N(s)\) has the same distribution as \(N(t)\) for all \(s \geq 0\). The distribution of events depends only on the length of the interval, not on its position in time.
    3. Orderliness (no simultaneous events): the probability of two or more events occurring in a very small interval \([t, t+\Delta t]\) is \(o(\Delta t)\), i.e. negligible relative to \(\Delta t\).

    As a consequence of these properties, the number of events in any interval of length \(t\) follows a Poisson distribution with mean \(\lambda t\):

    \[ P(N(t) = k) = \frac{e^{-\lambda t} (\lambda t)^k}{k!}, \quad k = 0, 1, 2, \ldots \]

    The variance is also \(\lambda t\), which means the relative variability \(\sqrt{\lambda t}/(\lambda t) = 1/\sqrt{\lambda t}\) decreases over time: the longer the horizon, the more predictable (in relative terms) the number of events.

    The exponential distribution as inter-event time

    Let \(T_1\) be the time to the first event. Its distribution is easy to derive using the connection to the Poisson process:

    \[ P(T_1 > t) = P(N(t) = 0) = e^{-\lambda t} \]

    Therefore, \(T_1 \sim \text{Exponential}(\lambda)\) with density function \(f(t) = \lambda e^{-\lambda t}\), mean \(1/\lambda\), and median \(\ln(2)/\lambda\).

    By the independent- and stationary-increments property, all the times between consecutive events \(T_1, T_2, T_3, \ldots\) are independent and identically distributed as \(\text{Exponential}(\lambda)\). This property is equivalent to the process being Poisson.

    The exponential distribution satisfies the famous memoryless property:

    \[ P(T > s + t \mid T > s) = P(T > t) \]

    In other words, the remaining time until the next event does not depend on how long you have already been waiting. This is the only continuous distribution with this property — the continuous analogue of the geometric distribution (the only discrete one with the memoryless property).

    How the simulator works, step by step

    The three tabs use the same generator. The simulator does not draw "how many events there are" from a Poisson distribution: it builds the process event by event, from the waiting times, and lets the Poisson distribution emerge by itself.

    1. The clock starts at t = 0.
    2. The waiting time until the next event is generated, with an exponential distribution of mean 1/λ. To do so, a random number U between 0 and 1 is drawn and −ln(U)/λ is computed.
    3. It is added to the clock: that is the time of the event.
    4. Steps 2 and 3 are repeated until the clock passes the horizon T. The times before T make up one sample path.

    Each tab looks at that same experiment from a different angle:

    • Sample path. It plots N(t), the cumulative number of events: a staircase that goes up one step at each event. The steps always have height 1 and irregular width, because the waiting times are random. The cards compare the expected value λT with the mean number of events of the paths drawn.
    • Distribution of N(T). It repeats the experiment hundreds or thousands of times and keeps only the number of events of each repetition. The bars are the proportion of repetitions with 0, 1, 2… events, and are compared with the probabilities of a Poisson with mean λT. The cards compare mean and variance: in a Poisson, both equal λT.
    • Inter-arrival times. It pools all the waiting times generated in all the repetitions and plots their histogram, on a density scale, next to the exponential curve λe−λt. The cards compare the mean (1/λ) and the median (ln 2/λ). The waiting time in progress when T is reached is also included; the reason is explained below.

    With the initial values, λ = 3 and T = 5, λT = 15 events are expected, with a standard deviation of √15 ≈ 3.9: it is normal to see paths with 11 or with 19 events. The exact number 15 only comes up about 10% of the time.

    Where the formulas come from

    How an exponential time is generated

    The computer only knows how to generate numbers U that are uniform between 0 and 1. To turn them into exponential times, the inverse transform method is used: set U equal to the exponential distribution function, \(F(t) = 1 - e^{-\lambda t}\), and solve for the time.

    \[ U = 1 - e^{-\lambda W} \quad\Longrightarrow\quad W = -\frac{\ln(1-U)}{\lambda}. \]

    Since 1 − U is also uniform between 0 and 1, \(W = -\ln(U)/\lambda\) can be used directly. The check is immediate:

    \[ \begin{aligned} P(W > t) &= P\big(-\ln U > \lambda t\big) \\ &= P\big(U < e^{-\lambda t}\big) = e^{-\lambda t}. \end{aligned} \]

    From the binomial to the Poisson

    Split the interval [0, t] into m very small pieces, of length t/m. In each piece there is an event with probability \(\lambda t/m\), independently of the others, and never more than one. The number of events is then binomial:

    \[ P(N = k) = \binom{m}{k}\left(\frac{\lambda t}{m}\right)^{k}\left(1 - \frac{\lambda t}{m}\right)^{m-k}. \]

    Rearranging the factors to see what happens as m grows:

    \[ \begin{aligned} P(N = k) = {} & \frac{(\lambda t)^k}{k!} \\ & \cdot \underbrace{\frac{m(m-1)\cdots(m-k+1)}{m^k}}_{\to\,1} \\ & \cdot \underbrace{\left(1 - \frac{\lambda t}{m}\right)^{m}}_{\to\,e^{-\lambda t}} \cdot \underbrace{\left(1 - \frac{\lambda t}{m}\right)^{-k}}_{\to\,1}. \end{aligned} \]

    In the limit you get the Poisson distribution:

    \[ P(N(t) = k) = \frac{e^{-\lambda t}(\lambda t)^k}{k!}. \]

    The mean and variance come from the same limit: the binomial has mean \(m \cdot \lambda t/m = \lambda t\) and variance \(\lambda t\,(1 - \lambda t/m) \to \lambda t\). That is why, on the "Distribution of N(T)" tab, the empirical mean and variance are close to each other.

    From the Poisson to the exponential, and back

    The first event taking longer than t is the same as there being no event up to t:

    \[ P(T_1 > t) = P(N(t) = 0) = e^{-\lambda t}, \]

    which is the exponential distribution. In general, the k-th event happens before t exactly when there have been at least k events up to t, \(P(S_k \le t) = P(N(t) \ge k)\). The time \(S_k\) is the sum of k independent exponential waits and follows a gamma (or Erlang) distribution with mean \(k/\lambda\). The two descriptions, counting events or measuring waits, are equivalent; the simulator generates the process with the second and checks the first.

    Memorylessness, worked out

    If you have already waited a time s with nothing happening, the probability of having to wait at least t more is

    \[ \begin{aligned} P(T > s + t \mid T > s) &= \frac{P(T > s+t)}{P(T > s)} \\ &= \frac{e^{-\lambda(s+t)}}{e^{-\lambda s}} = e^{-\lambda t}, \end{aligned} \]

    the same as at the start. With λ = 3 events per hour, the mean wait is 20 minutes; if 20 minutes have already gone by with no event, the mean remaining wait is still 20 minutes.

    The waiting-time paradox

    A surprising consequence: if you arrive at an arbitrary time, the interval between events you land in lasts 2/λ on average, twice the usual length. There is no contradiction: it is easier to land in a long interval than in a short one, precisely because it takes up more time.

    This affects how times are measured on the third tab. The interval in progress when T is reached is one of those "long" intervals. If it were discarded for being incomplete, the sample would be biased towards short times (with λ = 3 and T = 5, the mean would come out 7% below 1/λ, and no time could exceed T). That is why the simulator includes it in full: with all the intervals that start before T, the mean and the histogram match those of the exponential.

    Applications of the Poisson process

    The Poisson process is the reference model for rare events, or events that arrive randomly at a constant rate. Some classic applications:

    • Queueing theory (M/M/1): customer arrivals at a service point (a bank, a counter, a web server) are frequently modeled with a Poisson process with rate λ. M/M/1 queues also assume that service times are exponential with rate μ. System stability requires ρ = λ/μ < 1.
    • Radioactive decay: the emission of alpha or beta particles from a radioactive sample follows (with great precision) a Poisson process, since each nucleus decays independently with constant probability per unit of time.
    • Network traffic: data packets on telecommunications networks, requests to a web server, or incoming phone calls are modeled with Poisson processes as a first approximation.
    • Insurance claims: in actuarial science, the number of claims in a period is modeled with a Poisson distribution (a compound Poisson process when each claim has a random amount).
    • Epidemiology of rare diseases: the incidence of rare diseases in a population of size n, with small probability p of contracting it, can be approximated by Poisson(np).
    • Astronomy and particle physics: photons arriving at a detector, cosmic rays hitting a given area, or collisions in a particle accelerator.

    Generalizations of the Poisson process

    The homogeneous Poisson process (constant rate λ) has several important generalizations:

    • Non-homogeneous Poisson process: the rate varies with time, \(\lambda(t)\). The expected number of events in \([0, T]\) is \(\int_0^T \lambda(t)\,dt\). Useful when the intensity of the process changes over the course of the day (e.g., phone calls: more frequent at noon than at 3 a.m.).
    • Compound Poisson process: each event carries an associated random "size" or "severity" \(Y_i\). The process \(S(t) = \sum_{i=1}^{N(t)} Y_i\) is a compound Poisson process. It is the basic model in insurance risk for total claims.
    • Cox process (doubly stochastic Poisson): the rate \(\lambda\) is itself a stochastic process. It captures the overdispersion observed when the empirical variance exceeds the mean (something the pure Poisson cannot model).
    • Hawkes process: a self-exciting Poisson process in which each event temporarily raises the future intensity. It models contagion phenomena (e.g., earthquake aftershocks, the spread of news on social media, orders in financial markets).
    • Marked Poisson process: a generalization in which each event carries a "mark" that can contain additional information (event type, spatial location, magnitude, etc.).

    Frequently asked questions

    Why does the rate λ appear in both the Poisson and the exponential distributions?

    They are two sides of the same coin. λ is the occurrence rate of the process: how many events we expect per unit of time. In the Poisson distribution, λt is the expected number of events in the interval \([0,t]\). In the exponential distribution, \(1/\lambda\) is the expected time until the next event. If λ is large (many events per unit of time), the mean \(1/\lambda\) of the time between events is small — arrivals are frequent and the waits are short. Both formulations are equivalent: specifying one fully determines the other.

    Can the Poisson process be used when events are not fully independent?

    Not directly. Independence of increments is an essential property of the Poisson process: if knowledge of what has happened in the past changes our expectation of what will happen in the future (beyond the elapsed time), the process is not Poisson. For events with temporal correlation — e.g., earthquakes (an aftershock raises the probability of another), social media activity (a viral tweet generates more replies), or credit data (one customer's delinquency influences that of their neighbors) — richer models are used, such as Hawkes processes, Poisson processes with frailty, or generalized renewal processes.

    How does the Poisson process relate to the binomial distribution?

    When \(n \to \infty\) and \(p \to 0\) with \(np = \lambda\) fixed, the \(\text{Binomial}(n, p)\) distribution converges to the \(\text{Poisson}(\lambda)\) distribution. This is the law of rare events (or Poisson limit theorem). Intuitively: divide the interval \([0,T]\) into \(n\) small subintervals of length \(T/n\). An event can occur in each with probability \(p \approx \lambda T/n\). The total number of events is approximately \(\text{Binomial}(n, p)\), which converges to \(\text{Poisson}(\lambda T)\) as \(n \to \infty\). This derivation also justifies the properties of the Poisson process constructively.

    How should I interpret it when the empirical variance matches the mean?

    In the Poisson distribution, the theoretical variance equals the mean: \(\text{Var}(N(T)) = \mathbb{E}[N(T)] = \lambda T\). If in your simulations the empirical mean and variance are similar, that confirms the simulated process is indeed Poisson. If the empirical variance greatly exceeds the mean (overdispersion), it could indicate that the real underlying model is not pure Poisson, and it would be worth considering a negative binomial distribution or a Cox process.

    References and further reading

    • Poisson point process — Wikipedia. Definition and properties.
    • Rutherford, E., Geiger, H. and Bateman, H. (1910). The probability variations in the distribution of α particles. Philosophical Magazine, 20(118), 698–707. The count of alpha particles that confirmed the Poisson law experimentally.
    • Clarke, R. D. (1946). An application of the Poisson distribution. Journal of the Institute of Actuaries, 72(3), 481. The V-1 flying-bomb hits on London, scattered at random.
    • Kingman, J. F. C. (1993). Poisson Processes. Oxford University Press. A short, classic monograph.
    • Last, G. and Penrose, M. (2018). Lectures on the Poisson Process. Cambridge University Press.
    • Ross, S. M. (2019). Introduction to Probability Models (12th ed.). Academic Press. Chapter 5 covers the exponential and the Poisson process, including the waiting-time paradox.

    Related tools