Module contents
Lesson 1 of 31Review 60 min

Stochastic processes: the common language

An operational review of the vocabulary used throughout this module: a process as a family of random variables and as a random path, finite-dimensional laws and their consistency, filtrations as accumulated information, adapted processes and stopping times. A simple random walk provides a running example that returns as a Markov chain, a martingale and a limit producing Brownian motion.

After this lesson you can

  • Model a time-dependent phenomenon as a stochastic process by choosing its time set and state space.
  • Specify a process through its finite-dimensional distributions and check their consistency.
  • Decide whether a decision rule defines a stopping time with respect to a given filtration.
  • Simulate and analyze simple random-walk paths, including the distribution of their maximum and first-passage time.
  • Use a counterexample to explain how two modifications of a process can have different paths.

Before you start

A film, not a photograph

A closing-price distribution tells us which values are plausible, but not whether the price arrived there through a sudden drop or a series of small fluctuations. When studying a queue, arrival and departure times matter; for API traffic, whether peaks cluster; for temperature, how long a deviation persists. Dependence across time matters as much as the distribution at each instant.

Start with a deliberately simple model: a particle adds +1+1 or −1-1 at each step. Compare its paths, a cross-section at one instant and the effect of biasing the coin. The whole cloud and a single line answer different questions.

InteractiveA walk and its possible paths
−22−12−29190255075100stepFrequency at the cutS = 2: 3 of 10S = 10: 1 of 10S = -12: 1 of 10S = -10: 1 of 10S = -14: 1 of 10S = 0: 1 of 10S = -8: 1 of 10S = -4: 1 of 10
  • Observed paths and frequencies
  • Theoretical mean
  • Mean ± one standard deviation
Number of walks
0.50
60
Empirical mean at the cut−3.20
Theoretical mean at the cut0.00
Theoretical standard deviation7.75
Change the number of paths, the probability of an upward step and the cross-section time. The walk is generated with independent increments; the cross-sectional distribution is calculated from those paths. Compare drift with dispersion.

The drift of a walk with upward-step probability pp is n(2p−1)n(2p-1) and its standard deviation is 2np(1−p)2\sqrt{np(1-p)}. For a fair coin they are 00 and n\sqrt n: doubling the horizon does not double the typical width. With p≠1/2p\ne 1/2, the center grows linearly while the width grows as the square root. A one-standard-deviation envelope neither contains every path nor sets a boundary they must obey.

Variables and paths: two views of the same object

Choosing TT and EE is part of the model. A queue observed after each arrival can use T=NT=\N and E=NE=\N; an idealized temperature can use T=[0,∞)T=[0,\infty) and E=RE=\R. A time series is a sample on a grid: it does not determine what happened between observations. The particular observed path should also be distinguished from its law, which describes a set of possible paths.

In the walk, ξ1,ξ2,…\xi_1,\xi_2,\ldots are independent, P(ξi=1)=p\Pr(\xi_i=1)=p and P(ξi=−1)=1−p\Pr(\xi_i=-1)=1-p. The simple random walk starts at S0=0S_0=0 and satisfies Sn=∑i=1nξiS_n=\sum_{i=1}^n\xi_i. The increments are independent, but the levels are not: for m≤nm\le n, Sn=Sm+(Sn−Sm)S_n=S_m+(S_n-S_m) and Cov⁡(Sm,Sn)=4p(1−p)m\Cov(S_m,S_n)=4p(1-p)m. A level contains the entire accumulated past.

The law needs dependence

Consistency is essential: if the law of (X1,X2)(X_1,X_2) says X1=X2X_1=X_2 almost surely, its marginal for X1X_1 must be the separately stated law of X1X_1. For real-valued states, the Kolmogorov extension theorem constructs, from a consistent family, a measure on the product space RT\R^T with its product sigma-algebra. The finite-dimensional cylinders determine the law there. This alone does not guarantee continuous paths: regularity requires additional assumptions and, generally, a suitable choice of version.

Marginals are not enough. Let Z,Z1Z,Z_1 be independent fair coins. The processes (Z,Z)(Z,Z) and (Z,Z1)(Z,Z_1) have the same law at each instant, but P(X1=X2)\Pr(X_1=X_2) is respectively 11 and 1/21/2. Dependence changes the joint law even though each snapshot is identical.

A Gaussian process is one whose finite joint laws are Gaussian, including degenerate laws. It is specified by m(t)=EXtm(t)=\E X_t and K(s,t)=Cov⁡(Xs,Xt)K(s,t)=\Cov(X_s,X_t): for each list, the mean is the vector of mm and the covariance is the matrix with entries KK. Not every function is a valid covariance: it must be symmetric and ∑i,jaiajK(ti,tj)≥0\sum_{i,j}a_i a_j K(t_i,t_j)\ge 0 for every finite list and all coefficients. This positivity makes each Gaussian matrix valid; Gaussian marginalization provides consistency. The multivariate Gaussian and its marginalization justify this shortcut.

Available information and decisions without foresight

A trading decision at time tt cannot use the next day’s maximum. A filtration (Ft)(\mathcal F_t) is an increasing family of sub-sigma-algebras of F\mathcal F: if s≤ts\le t, Fs⊆Ft\mathcal F_s\subseteq\mathcal F_t. Each event in Ft\mathcal F_t can be determined from information available up to tt. A sigma-algebra is not a list of known values: it also includes every event that can be formed from them.

The process is adapted to (Ft)(\mathcal F_t) if XtX_t is Ft\mathcal F_t-measurable for each tt. Its natural filtration is FtX=σ(Xs:s≤t)\mathcal F_t^X=\sigma(X_s:s\le t), the smallest containing observations of the process itself up to that time. A filtration may contain additional information, including future information; adaptation is checked with respect to the chosen filtration. The generated sigma-algebra formalizes exactly what can be determined.

If XX is adapted in discrete time, τA=inf⁡{n≥0:Xn∈A}\tau_A=\inf\{n\ge0:X_n\in A\} is a stopping time for measurable AA, because {τA≤n}=⋃k=0n{Xk∈A}∈Fn\{\tau_A\le n\}=\bigcup_{k=0}^n\{X_k\in A\}\in\mathcal F_n. The first time two consecutive positive increments are observed is also a stopping time: it only requires inspecting the past. By contrast, the time of the last maximum over a fixed horizon generally is not. Two paths can agree up to nn and then make the maximum observed at nn either the last maximum or not.

InteractiveDeciding from the past
  • History A
  • History B

The solid part is observed and the dashed part shows possible continuations, not available information. The last maximum is defined here at fixed horizon n = 11; ties use the last time.

Rule
7
Has the rule occurred in A?Yes
Has the rule occurred in B?No
Same past, different answers: the available information cannot decide. The last-maximum rule looks into the future.
Reveal the walk step by step and compare a first arrival with the choice of the last maximum. The latter requires distinguishing futures that still share the same history.

This indistinguishable-histories test is operational: if two histories with the same prefix require different answers about whether stopping has occurred, the event does not belong to the information in that prefix. A finite simulation must specify the horizon and the convention for non-arrival. In continuous time, measurability of first hitting times requires additional assumptions about the paths and filtration; the finite-union proof no longer applies directly.

The law of the walk, maximum and first passage

If NnN_n counts upward steps, Nn∼Bin⁡(n,p)N_n\sim\Bin(n,p) and Sn=2Nn−nS_n=2N_n-n. Therefore, for kk with the same parity as nn and ∣k∣≤n|k|\le n,

P(Sn=k)=(n(n+k)/2)p(n+k)/2(1−p)(n−k)/2.\Pr(S_n=k)=\binom{n}{(n+k)/2}p^{(n+k)/2}(1-p)^{(n-k)/2}.

Outside those values the probability is zero. Summing the means and variances of independent increments gives the scales in the first figure. The formula also shows that the distribution is not continuous, although a normal approximation can be useful over long horizons.

For p=1/2p=1/2, write Mn=max⁡0≤j≤nSjM_n=\max_{0\le j\le n}S_j and τa=inf⁡{j≥0:Sj=a}\tau_a=\inf\{j\ge0:S_j=a\}, with integer a≥1a\ge1. The reflection principle gives

P(Mn≥a)=P(Sn≥a)+P(Sn≥a+1).\Pr(M_n\ge a)=\Pr(S_n\ge a)+\Pr(S_n\ge a+1).

To see this, separate paths that reach aa and end at k≥ak\ge a from those ending at k<ak<a. For the latter, reflect the increments after the first hit of aa. The endpoint becomes 2a−k>a2a-k>a; the transformation is a probability-preserving bijection because the coin is fair. The sum over reflected endpoints is P(Sn>a)\Pr(S_n>a). The identity applies to a finite horizon and does not claim that the maximum has exactly the same law as ∣Sn∣|S_n|.

Also, for k≥1k\ge1, P(τa=k)=akP(Sk=a)\Pr(\tau_a=k)=\frac{a}{k}\Pr(S_k=a), with value zero when parity or reachability rules it out. This first-passage identity gives the point mass; summing up to nn must agree with the preceding maximum probability. When a path has not arrived by the horizon, its time is censored: this is not an observation that it will never arrive.

The formula follows by counting paths. For a first hit at step kk, the penultimate value is a−1a-1 and the last increment is positive. Among prefixes of k−1k-1 steps ending at a−1a-1, remove those that have already reached aa. Reflecting each prefix after its first hit puts the latter in bijection with those ending at a+1a+1. The desired count is therefore

(k−1(k+a−2)/2)−(k−1(k+a)/2)=ak(k(k+a)/2).\binom{k-1}{(k+a-2)/2}-\binom{k-1}{(k+a)/2} =\frac{a}{k}\binom{k}{(k+a)/2}.

A binomial coefficient outside its range is zero. Each complete sequence has probability 2−k2^{-k}, and the expression on the right gives the stated formula. Equality depends on both directions having the same probability; with drift, reflection does not preserve each path’s weight.

Lab: simulate without confusing censoring with non-arrival

We build 100000100000 fair walks in batches to limit browser memory. Each row contains the increments of one path, and column zero of the cumulative sum corresponds to the initial time. The exact probability is calculated by summing the binomial law and applying reflection, without using the simulation to define the reference. We print the approximate Monte Carlo error p^(1−p^)/N\sqrt{\hat p(1-\hat p)/N}: this is not a deterministic guarantee.

[ ]Maxima and first hitting timesBrowser
import numpy as np
from math import comb, sqrt

N, n, a, lote = 100_000, 100, 5, 5_000
rng = np.random.default_rng(2601)
hist_primero = np.zeros(n + 1, dtype=np.int64)
suma_cuadrados = np.zeros(3, dtype=np.float64)
cortes = np.array([25, 50, 100])
for inicio in range(0, N, lote):
    tam = min(lote, N - inicio)
    inc = 2 * rng.integers(0, 2, size=(tam, n), dtype=np.int8) - 1
    caminos = np.cumsum(inc, axis=1, dtype=np.int16)
    maximos = np.maximum.accumulate(caminos, axis=1)
    acceso = maximos >= a
    llega = acceso.any(axis=1)
    tiempos = acceso.argmax(axis=1)[llega] + 1
    hist_primero += np.bincount(tiempos, minlength=n + 1)
    suma_cuadrados += (caminos[:, cortes - 1].astype(float) ** 2).sum(axis=0)

def cola(k):
    return sum(comb(n, j) for j in range(n + 1) if 2*j - n >= k) / 2**n

empirica = hist_primero.sum() / N
exacta = cola(a) + cola(a + 1)
print('probabilidad empírica:', round(empirica, 5))
print('probabilidad exacta:', round(exacta, 5))
print('error estándar estimado:', round(sqrt(empirica*(1-empirica)/N), 5))
print('sin acceso hasta el horizonte:', N - hist_primero.sum())
print('RMS / raíz del tiempo:', np.round(np.sqrt(suma_cuadrados / N) / np.sqrt(cortes), 4))
print('primeros accesos en pasos 5, 7, 9:', hist_primero[[5, 7, 9]])

The RMS is E[Sn2]=n\sqrt{\E[S_n^2]}=\sqrt n in the fair model. The simulation estimates this moment at three time points; the ratio should approach one, subject to fluctuations. Using argmax is correct only after filtering by any: a row of false values would produce a misleading zero index. Notice that >= a is equivalent here to reaching aa because jumps have size one; this would not hold for arbitrary increments.

Now check the first-passage distribution against its formula, in addition to the total. The same generator is not reset between batches; the specific results form a reproducible realization, not universal constants.

[ ]Exact first-hitting lawBrowser
def masa_primer_paso(k, nivel):
    if k < nivel or (k + nivel) % 2:
        return 0.0
    return nivel / k * comb(k, (k + nivel)//2) / 2**k

print('masas exactas en pasos 5, 7, 9:',
      [round(masa_primer_paso(k, a), 6) for k in (5, 7, 9)])
print('suma de masas hasta n:', round(sum(masa_primer_paso(k, a) for k in range(1, n+1)), 6))
print('reflexión:', round(exacta, 6))
teorica = np.array([0.0] + [masa_primer_paso(k, a) for k in range(1, n+1)])
empirica_pasos = hist_primero / N
print('máxima diferencia absoluta entre masas:', round(np.max(np.abs(empirica_pasos - teorica)), 6))
print('pasos 5 a 15: empírica, exacta')
for k in range(5, 16, 2):
    print(k, round(empirica_pasos[k], 6), round(teorica[k], 6))
print('P(S_10 = 0):', comb(10, 5) / 2**10)

Equality at each time does not imply equality of paths

Two processes X,YX,Y on the same space are modifications if, for each fixed tt, P(Xt=Yt)=1\Pr(X_t=Y_t)=1. They are indistinguishable if P(Xt=Yt para todo t)=1\Pr(X_t=Y_t\text{ para todo }t)=1, provided that event is defined in the sigma-algebra under consideration. The second statement implies the first. On a countable time set the converse also holds, because a countable union of null events is null. Over a continuum we cannot simply take that union.

Let UU be uniform on [0,1][0,1], Xt=0X_t=0 and Yt=1{t=U}Y_t=\mathbf 1_{\{t=U\}}. For each fixed tt, P(U=t)=0\Pr(U=t)=0, so they are modifications. However, for each realization there is a time t=Ut=U where Yt=1Y_t=1: no path of YY agrees with that of XX for all [0,1][0,1]. The figure represents an isolated point, not a positive interval or permanent jump.

InteractiveA point invisible at every fixed cross-section
  • Xt=0X_t=0 and Yt=0Y_t=0 except at UU
  • YU=1Y_U=1
  • Cut tt
The open circle at (U,0)(U,0) marks the missing value on the graph of YY; the filled point at (U,1)(U,1) is its only nonzero value. There is no sustained interval or jump.

The hundredths grid is used to select values on screen. In the model, UU is continuously uniform on [0,1][0,1]: for every fixed tt, P(U=t)=0\Pr(U=t)=0. If you choose t=Ut=U after observing UU, it is no longer a fixed time independent of the realization.

0.37
0.60
XtX_t0
YtY_t on this path0
Do the complete paths coincide?No
Choose a fixed time and compare the processes; then inspect the entire path. The value at the random time U is one, although every time fixed in advance has zero probability of coinciding with U.

Regularity can remove this ambiguity. If two modifications have almost surely continuous paths on [0,1][0,1], they agree simultaneously at every rational time with probability one because the rationals are countable; by continuity they agree at all real times. They are therefore indistinguishable. The distinction matters when discussing maxima, crossings or continuity, which are properties of an entire path rather than a single marginal.

Exercises

QuizWhen can you decide?
For a walk observed up to horizon 10, which rules are stopping times with respect to its natural filtration? First hits are sought up to step 10 and, if they do not occur, are encoded as infinity.

More than one answer may be correct.

NumericReturn to the origin
A symmetric simple walk starts at zero. What is the probability of being at zero after ten steps?
ProofCombining stopping rules
Prove: If τ\tau and σ\sigma are discrete stopping times, prove that their minimum and maximum are also stopping times.
0
Work with the events indicating whether the rule has already stopped by time n.

Step 1 of 3. What event says that the minimum does not exceed n?

QuizCompatible laws
At times 1 and 2, both stated marginals are Bernoulli(1/2). Which joint laws are compatible with them?

More than one answer may be correct.

CodeFirst hit of a set
Implement primer_acceso(caminos, estados). caminos is a two-dimensional numeric array with at least one column: each row is a path and each column a time starting at zero. Return two arrays: indices of the first hit and the corresponding values. If there is no hit, return index -1 and value NaN. estados is a collection of numbers.
import numpy as np

def primer_acceso(caminos, estados):
  pass
Shift+Enter to run

Road map

The walk will reappear as a Markov chain, because the present determines the distribution of the next step, and as a martingale when the coin is fair. Counting processes describe arrivals; time series allow us to study dependence and prediction; Brownian motion and Itô calculus deal with continuous paths. The joint law and available information matter in all of them. Conditional expectation, its tower property, and Gaussian conditioning will be tools for turning information into predictions.

Key idea

A process is a family of variables on a common probability space and, at the same time, a random path. Joint laws describe dependence; a filtration records what is known and a stopping time respects that information. In continuous time, almost-sure equality at each instant does not suffice to identify entire paths.