Stochastic Modeling
ZHAW School of Engineering
Fundamentals¶
Probability Space & Axioms¶
A probability space is a triple (Ω,A,P) where:
Ω: Sample space - set of all possible outcomes
A: σ-algebra - set of all measurable events (subsets of Ω)
P: Probability measure satisfying Kolmogorov’s Axioms:
1.2.3.0≤P(E)≤1∀E∈AP(Ω)=1P(i=1⋃∞Ei)=i=1∑∞P(Ei)for pairwise disjoint Ei Key Properties¶
P(∅)P(Ac)P(A∖B)P(A∪B)=0=1−P(A)=P(A)−P(A∩B)=P(A)+P(B)−P(A∩B)(Inclusion-Exclusion) Conditional Probability¶
Interpretation: Restricts the sample space to F and considers the relative frequency of E within F.
Independence¶
For n events E1,E2,…,En:
P(i=1⋂nEi)=i=1∏nP(Ei) Important: Independence is pairwise and for all subsets, not just pairs.
Law of Total Probability¶
For a partition A1,A2,…,An of Ω:
P(E)=i=1∑nP(E∣Ai)⋅P(Ai) Simplified (for binary partition):
P(E)=P(E∣A)⋅P(A)+P(E∣Ac)⋅P(Ac) Bayes’ Theorem¶
P(A∣E)=P(E)P(E∣A)⋅P(A)=P(E∣A)⋅P(A)+P(E∣Ac)⋅P(Ac)P(E∣A)⋅P(A) Example: Medical testing - given test result, compute probability of disease.
Random Variables¶
Definition¶
A random variable (RV) X:Ω→R assigns a numerical value to each outcome.
Types of Random Variables¶
| Type | Definition | Example |
|---|
| Discrete | Takes finite or countable values | Dice roll, coin toss |
| Continuous | Takes uncountable values | Height, time |
Probability Mass Function (PMF)¶
For discrete RV X:
P(X=xi)=pX(xi)where i∑pX(xi)=1 Probability Density Function (PDF)¶
For continuous RV X:
P(a≤X≤b)=∫abfX(x)dxwhere ∫−∞∞fX(x)dx=1 Distribution Function (CDF)¶
For any RV X:
FX(t)=P(X≤t)={∑xi≤tP(X=xi)∫−∞tfX(x)dxfor discrete Xfor continuous X Properties: FX is right-continuous, non-decreasing, with limt→−∞FX(t)=0 and limt→∞FX(t)=1.
Expectation (Mean)¶
E[X]={∑ixiP(X=xi)∫−∞∞xfX(x)dxfor discrete Xfor continuous X Linearity of Expectation:
E[aX+bY]=aE[X]+bE[Y]for any RVs X,Y and constants a,b Important: Linearity holds regardless of independence.
Variance¶
Var(X)=E[(X−E[X])2]=E[X2]−(E[X])2 Properties:
Var(aX)Var(X+Y)Var(X+c)=a2Var(X)=Var(X)+Var(Y)+2Cov(X,Y)=Var(X)for constant c Moment Generating Function (MGF)¶
ϕX(t)=E[etX]={∑ietxiP(X=xi)∫−∞∞etxfX(x)dxfor discrete Xfor continuous X Important Property: The n-th derivative at t=0 gives the n-th moment:
ϕX(n)(0)=E[Xn] Taylor Expansion:
ϕX(t)=n=0∑∞n!tnE[Xn] Discrete Distributions¶
| PMF P(X=k) | Support | E[X] | Var(X) | MGF |
|---|
| Uniform (a,b),n=b−a+1 | n1 | k∈{1,…,n} | 2a+b | 12n2−1 | n(1−et)eat−e(b+1)t |
| Bernoulli (p) | pk(1−p)1−k | k∈{0,1} | p | p(1−p) | pet+(1−p) |
| Binomial (n,p) | (kn)pk(1−p)n−k | k∈{0,…,n} | np | np(1−p) | (pet+1−p)n |
| Geometric (p) | (1−p)k−1p | k∈N | p1 | p21−p | 1−(1−p)etpet |
| Poisson (λ) | k!λke−λ | k∈N0 | λ | λ | eλ(et−1) |
Bernoulli Distribution¶
Models a single yes/no experiment with success probability p.
Example: Coin toss, single trial in an experiment.
Binomial Distribution¶
Models the number of successes in n independent Bernoulli trials.
Geometric Distribution¶
Models the number of trials until the first success.
Example: Number of coin tosses until the first head appears.
Coupon Collector’s Problem¶
Problem: How many boxes must you buy to collect all n different coupons?
Solution: Let Sn=X1+X2+…+Xn where Xk∼Geom(nn−(k−1)).
E[Sn]=nk=1∑nk1=nHn≈nln(n)+γn where Hn=∑k=1nk1 is the n-th harmonic number and γ≈0.5772 is the Euler-Mascheroni constant.
Continuous Distributions¶
| PDF f(x) | Support | E[X] | Var(X) | MGF |
|---|
| Uniform (a,b) | b−a1 | x∈[a,b] | 2a+b | 12(b−a)2 | {t(b−a)etb−eta1for t=0for t=0 |
| Exponential (λ) | λe−λx | x≥0 | λ1 | λ21 | λ−tλ |
| Normal (μ,σ2) | 2πσ21e−2σ2(x−μ)2 | x∈R | μ | σ2 | etμ+21t2σ2 |
Exponential Distribution¶
Memoryless Property: For X∼Exp(λ):
P(X>s+t∣X>t)=P(X>s)=e−λs Interpretation: The probability of surviving an additional s units of time is independent of how long the component has already survived.
Normal Distribution¶
Standard Normal: Z∼N(0,1) with standard normal CDF FX(z)=Φ(z)=2π1∫−∞ze−t2/2dt
Standardization: If X∼N(μ,σ2), then Z=σX−μ∼N(0,1)
Probability Calculation: P(X≤t)=Φ(σt−μ)
Symmetric Properties: Φ(−z)=1−Φ(z)andΦ(0)=0.5
Joint Distributions & Independence¶
Joint Distribution Function¶
For two RVs X,Y:
FX,Y(a,b)=P(X≤a,Y≤b) Marginal Distributions:
FX(a)=b→∞limFX,Y(a,b) Joint PMF/PDF¶
Discrete:
pX,Y(x,y)=P(X=x,Y=y) Continuous:
fX,Y(x,y)such that ∫∫AfX,Y(x,y)dxdy=P((X,Y)∈A) Marginal PDF:
fX(x)=∫−∞∞fX,Y(x,y)dy Independence of Random Variables¶
X and Y are independent if one of the following is true:
FX,Y(a,b)fX,Y(x,y)P(X=x,Y=y)=FX(a)FY(b)∀a,b=fX(x)fY(y), (continous RV)=P(X=x)P(Y=y), (discrete RV) Consequences of Independence:
E[XY]Cov(X,Y)Var(X+Y)ϕX+Y(t)=E[X]E[Y]=0=Var(X)+Var(Y)=ϕX(t)ϕY(t) Covariance & Correlation¶
Covariance:
Cov(X,Y)=E[(X−E[X])(Y−E[Y])]=E[XY]−E[X]E[Y] Correlation Coefficient (normalized Covariance):
ρX,Y=Var(X)Var(Y)Cov(X,Y)∈[−1,1] Properties:
Cov(X,X)Cov(X,Y)Cov(aX+b,cY+d)Cov(X+Y,Z)Cov(X,Y+Z)Var(X+Y)=Var(X)=Cov(Y,X)=acCov(X,Y)=Cov(X,Z)+Cov(Y,Z)=Cov(X,Y)+Cov(X,Z)=Var(X)+Var(Y)+2Cov(X,Y) Conditional Distributions & Expectation¶
Conditional PMF/PDF¶
Discrete:
PX∣Y(x∣y)=P(X=x∣Y=y)=P(Y=y)P(X=x,Y=y) Continuous:
fX∣Y(x∣y)=fY(y)fX,Y(x,y) Conditional Expectation¶
Discrete:
E[X∣Y=y]=x∑xPX∣Y(x∣y) Continuous:
E[X∣Y=y]=∫−∞∞xfX∣Y(x∣y)dx Important: E[X∣Y] is itself a random variable (function of Y)
Law of Total Expectation¶
E[X]=E[E[X∣Y]] For discrete Y:
E[X]=y∑E[X∣Y=y]P(Y=y) For continuous Y:
E[X]=∫−∞∞E[X∣Y=y]fY(y)dy Conditional Variance¶
Var(X∣Y=y)=E[X2∣Y=y]−(E[X∣Y=y])2 Law of Total Variance:
Var(X)=E[Var(X∣Y)]+Var(E[X∣Y]) Mean Squared Error (MSE) Minimization¶
Proof: Follows from the orthogonality principle in Hilbert spaces.
For a continuous RV X with density fX(x) and a differentiable, strictly monotone function g:
Y=g(X)⟹fY(y)=fX(g−1(y))⋅∣∣dydg−1(y)∣∣=∣g′(g−1(y))∣fX(g−1(y)) Validity: Only for y in the range of g; fY(y)=0 outside this range.
If X∼Unif([0,1]) and Y=eX:
Y∼Exp(1) on [1,e]with fY(y)=y1 for y∈[1,e] Verification: ∫1ey1dy=ln(e)−ln(1)=1.
Multiple Variables¶
For Y1=g1(X1,X2) and Y2=g2(X1,X2) with invertible transformation:
fY1,Y2(y1,y2)=fX1,X2(g1−1(y1,y2),g2−1(y1,y2))⋅∣J∣ where ∣J∣ is the absolute value of the Jacobian determinant.
Limit Theorems¶
Law of Large Numbers (LLN)¶
Weak LLN: For i.i.d. RVs X1,X2,… with E[Xi]=μ and Var(Xi)=σ2<∞:
nSn=nX1+X2+…+XnPμas n→∞ Strong LLN: Under the same conditions (with finite mean):
P(n→∞limnSn=μ)=1(almost sure convergence) Interpretation: The sample mean converges to the true mean as n→∞.
Central Limit Theorem (CLT)¶
For i.i.d. RVs X1,X2,… with E[Xi]=μ and Var(Xi)=σ2<∞:
Z=σSn−μdN(0,1)as n→∞ Chebyshev’s Inequality¶
For any RV X with E[X]=μ and Var(X)=σ2:
P(∣X−μ∣≥ε)≤ε2σ2∀ε>0 Application: Provides a bound on the probability of deviation from the mean.
Example: For Sn∼Bin(n,p):
P(∣Sn−np∣≥ε)≤ε2np(1−p) Markov’s Inequality¶
For any non-negative RV X:
P(X≥a)≤aE[X]∀a>0 Stochastic Processes¶
Definition¶
A stochastic process is a collection of RVs X={Xt:t∈T} where T is an index set (usually time).
Representation:
X:T×Ω→Rvia (t,ω)↦Xt(ω) Characterization¶
A stochastic process is characterized by its finite-dimensional distributions:
FXt1,…,Xtk(x1,…,xk)=P(Xt1≤x1,…,Xtk≤xk) for all k≥1 and t1<t2<…<tk.
Mean & Correlation Functions¶
Mean Function
mX(t)=E[Xt] Correlation Function
RX(t1,t2)=E[Xt1Xt2] Zero-mean processes: RX(t1,t2)=Cov(Xt1,Xt2)
| Definition | RX(t1,t2)=E[Xt1Xt2] |
|---|
| White Noise | Xt∼i.i.d.(0,σ2) | σ2δt1,t2 for δt1,t2 := if (t1=t2) 1 else 0 |
| Wiener Process | Wt∼N(0,t) | min(t1,t2) |
| AR(1) Process | Xt=ϕXt−1+ϵt | 1−ϕ2σ2ϕ∣t1−t2∣ (if ∣ϕ∣<1) |
Covariance Function
CX(t1,t2)=RX(t1,t2)−mX(t1)mX(t2) Stationary Processes¶
Definition: A process is stationary if its finite-dimensional distributions are invariant under time shifts:
(Xt1,…,Xtk)=d(Xt1+s,…,Xtk+s)∀s Wide-Sense Stationary (WSS):
Constant mean: mX(t)=m for all t
Correlation depends only on time difference: RX(t1,t2)=RX(∣t2−t1∣)
Examples of Stochastic Processes¶
| Description | mX(t) | Var(Xt) | RX(t1,t2) |
|---|
| Bernoulli | Xn i.i.d. ±1 valued | 2p−1 | 4p(1−p) | (2p−1)2 for t1=t2 |
| Random Walk | Xn=∑i=1nBi | 0 (if p=1/2) | n | min(t1,t2) |
| Brownian Motion | Continuous limit of RW | 0 | t | min(t1,t2) |
| Poisson | Counts events in time | λt | λt | λmin(t1,t2) |
Bernoulli Process¶
Xn i.i.d. with P(Xn=1)=p and P(Xn=−1)=1−p.
Random Walk (RW)¶
X0=0, Xn=Xn−1+Bn where Bn i.i.d. ±1 valued.
Symmetric RW: p=1/2
Recurrence: In d=1,2, RW is recurrent (returns to origin infinitely often) with probability 1
Transience: In d≥3, RW is transient (never returns to origin) with probability 1
CLT for RW:
nXndN(0,1)for symmetric RW Brownian Motion (BM)¶
Models particle movement in a liquid (Einstein, 1905)
Models stock market fluctuations (Bachelier, 1900)
Continuous paths, nowhere differentiable
Bt∼N(0,t) for each t
Independent increments
Connection to RW: Scaled limit of symmetric RW as step size →0 and time →∞.
Poisson Process¶
Nt counts the number of events in [0,t] for a process with:
N0=0
Independent increments
Ns+t−Ns∼Pois(λt)
Properties:
E[Nt]=λt
Var(Nt)=λt
CN(t1,t2)=λmin(t1,t2)
Inter-arrival times Ti∼Exp(λ) and independent
Thinning Property: If each event is kept with probability p, the thinned process is PP(pλ).
Merging Property: Sum of independent PP(λ1) and PP(λ2) is PP(λ1+λ2).
Random Telegraph Process¶
Xt=(−1)Nt where Nt is a Poisson process.
Mean: E[Xt]=e−2λt
Correlation: RX(t1,t2)=e−2λ∣t2−t1∣
Markov Chains¶
Definition¶
A Markov Chain (MC) is a discrete-time stochastic process with the Markov Property:
P(Xn+1=xn+1∣Xn=xn,Xn−1=xn−1,…,X0=x0)=P(Xn+1=xn+1∣Xn=xn) Interpretation: Given the present, the future is independent of the past.
Transition Probabilities¶
One-step:
pij=P(Xn+1=j∣Xn=i) Transition Matrix:
P=⎝⎛p11p21⋮pk1p12p22⋮pk2⋯⋯⋱⋯p1kp2k⋮pkk⎠⎞ Properties: pij≥0 and ∑jpij=1 for all i (stochastic matrix).
m-step:
pij(m)=P(Xn+m=j∣Xn=i) Chapman-Kolmogorov Equations:
pij(m+n)=k∈S∑pik(m)pkj(n) Matrix Form: P(m+n)=PmPn and P(m)=Pm.
Classification of States¶
Accessible: i→j if pij(n)>0 for some n≥0
Communicating: i↔j if i→j and j→i
Communication Classes: Equivalence classes under ↔
Irreducible: All states communicate (single communication class)
Period: di=gcd{n≥1:pii(n)>0}
Aperiodic: di=1 for all i
Stationary Distributions¶
A probability vector π=(π1,π2,…) is a stationary distribution if:
π=πPandi∑πi=1,πi≥0 Interpretation: If X0∼π, then Xn∼π for all n.
Existence:
Convergence¶
Corollary: Every row of Pn converges to π as n→∞.
Problem: Rank web pages based on link structure.
Model: Random surfer model with:
Google Matrix:
G=αS+(1−α)n1eeT where S is the stochastic matrix from the web graph (with fixes for dangling nodes).
Properties:
Dangling Nodes: Pages without outlinks. Solution: Add uniform row.
Rank Sinks: Groups of pages that trap the random surfer. Solution: Use teleportation.
Continuous-Time Markov Chains¶
Holding Times¶
For a continuous-time MC, the time spent in state i before jumping:
Poisson Process (Special Case)¶
A counting process Nt is a Poisson Process with rate λ>0 if:
N0=0
Independent increments
Ns+t−Ns∼Pois(λt)
Key Properties:
Nt∼Pois(λt)
E[Nt]=λt
Var(Nt)=λt
Inter-arrival times Ti∼Exp(λ) and independent
Construction: If Ti∼Exp(λ) i.i.d., then Nt=max{n:∑i=1nTi≤t} is a Poisson process.
Important Examples from Exercises¶
Conditional Probability Examples¶
Example 1: Two dice, sum equals 6 vs. first die equals 4
E1: sum equals 6, P(E1)=365
E3: first die equals 4, P(E3)=61
P(E1∣E3)=61>P(E1) (dependent!)
P(E2∣E3)=61=P(E2) (independent!)
Example 2: Lottery probabilities
Probability of winning with 6 out of 48: P=(648)1≈1.2×10−7
Probability that at least one of H participants wins: 1−(1−(648)1)H
Conditional Expectation Examples¶
Exercise from Week 8: Given joint density fX,Y(x,y)=6xy(2−x−y) for 0<x,y<1:
E[X∣Y=y]=2(4−3y)5−4yfor 0<y<1 Variance Calculation¶
Exercise from Week 8: For fX,Y(x,y)=181e−(x+y) for 0<y<x:
Var(X∣Y=2)=36 Geometric Distribution Proof¶
Exercise from Week 8: If X∼Pois(Y) and Y∼Exp(λ), then W=X+1∼Geom(λ+1λ).
Markov Chain Examples¶
Example: Gambler’s Ruin
States: {0,1,2,3} (0 and 3 are absorbing)
Communication classes: {0},{1,2},{3}
Not irreducible (multiple classes)
Example: Simple Two-State Chain
States: {1,2}
Transition matrix: P=(0110)
Stationary distribution: π=(1/2,1/2)
Periodic with period 2
Poisson Process Examples¶
Example: Machine failures with rate λ=2 per week.
P(no failure in 2 weeks)=e−4
P(at most 1 failure in 2 weeks)=e−4+4e−4=5e−4
P(inter-arrival > 5 weeks)=e−10