2025-11-10T02:38:09.804207

Stochastic Simulation and Monte Carlo Method

Mirzaei
These lecture notes are intended to cover some introductory topics in stochastic simulation for scientific computing courses offered by the IT department at Uppsala University, as taught by the author. Basic concepts in probability theory are provided in the Appendix A, which you may review before starting the upcoming sections or refer to as needed throughout the text.
academic

Stochastic Simulation and Monte Carlo Method

Basic Information

  • Paper ID: 2501.00997
  • Title: Stochastic Simulation and Monte Carlo Method
  • Author: Davoud Mirzaei (Uppsala University)
  • Classification: math.NA cs.NA stat.CO stat.OT
  • Publication Date: November 1, 2024 (2nd Edition)
  • Paper Link: https://arxiv.org/abs/2501.00997

Abstract

This is a set of teaching lecture notes for the scientific computing course in the IT department at Uppsala University. The content covers introductory topics in stochastic simulation, including Monte Carlo methods, random variable generation, stochastic processes, and Markov Chain Monte Carlo (MCMC). Appendix A provides fundamental concepts in probability theory as the theoretical foundation for understanding subsequent chapters.

Research Background and Motivation

Core Problems

The lecture notes aim to address the selection and application of deterministic versus stochastic models in scientific computing:

  1. Modeling Method Selection: How to choose appropriate methods between deterministic and stochastic modeling
  2. Stochastic Simulation Techniques: How to efficiently generate and utilize random variables for complex system simulation
  3. Parameter Estimation: How to conduct Bayesian parameter estimation in uncertain environments

Significance Analysis

Stochastic simulation holds important significance in modern scientific computing:

  • Real System Modeling: Many real-world systems contain inherent randomness and uncertainty
  • High-Dimensional Integration: Monte Carlo methods possess unique advantages in high-dimensional integration
  • Complex System Analysis: Complex systems such as biological systems, financial markets, and epidemic propagation require stochastic modeling

Limitations of Existing Methods

  • Deterministic Methods: Cannot capture system stochastic fluctuations and uncertainty
  • Traditional Numerical Methods: Computational complexity grows dramatically for high-dimensional problems
  • Parameter Estimation Challenges: Complex posterior distributions are difficult to compute directly

Core Contributions

  1. Systematic Teaching Framework: Provides a complete pedagogical system from fundamental probability theory to advanced MCMC methods
  2. Practical Algorithm Implementation: Presents Python implementations of key algorithms, including random variable generation, Gillespie algorithm, and MCMC
  3. Multi-Domain Application Examples: Covers applications in radioactive decay, epidemic propagation, financial option pricing, and biochemical reactions
  4. Theory-Practice Integration: Organically combines mathematical theory with practical programming implementation

Methodology Details

Task Definition

The lecture notes primarily address the following core tasks:

  • Random Variable Generation: Efficiently generate random samples from given distributions
  • Monte Carlo Integration: Compute complex integrals using random sampling methods
  • Stochastic Process Simulation: Model Markov chains, Brownian motion, and other stochastic processes
  • Parameter Estimation: Conduct Bayesian parameter inference through MCMC methods

Core Method Architecture

1. Random Variable Generation Methods

Inverse Transform Method

# Basic idea: If U ~ U(0,1), then X = F^(-1)(U) ~ f
def inverse_transform_sampling(cdf_inverse, n):
    U = np.random.uniform(0, 1, n)
    return cdf_inverse(U)

Acceptance-Rejection Method

  • Use proposal distribution g(x) and constant C to bound target distribution f(x)
  • Acceptance probability: α = min{f(X)/(Cg(X)), 1}
  • Efficiency: P(acceptance) = 1/C

2. Monte Carlo Integration

Basic Monte Carlo Estimation For integral I = ∫g(x)f(x)dx:

I ≈ (1/N) Σ g(xi), xi ~ f

Importance Sampling

I = ∫g(x)f(x)dx = ∫g(x)[f(x)/ℓ(x)]ℓ(x)dx
I ≈ (1/N) Σ g(xi)w(xi), xi ~ ℓ, w(xi) = f(xi)/ℓ(xi)

3. Stochastic Process Generation

Markov Chain Generation

  • State transition matrix P = (pij)
  • Stationary distribution π satisfies πP = π

Brownian Motion Generation

# Wt+1 = Wt + √(Δt) * Z, Z ~ N(0,1)
def brownian_motion(t_vec, dim):
    W = np.zeros([dim, len(t_vec)])
    for k in range(len(t_vec)-1):
        Z = np.random.normal(0, 1, dim)
        dt = t_vec[k+1] - t_vec[k]
        W[:, k+1] = W[:, k] + np.sqrt(dt) * Z
    return W

4. Gillespie Algorithm (SSA)

Core Steps:

  1. Compute total propensity function: a(y) = Σ wj(y)
  2. Generate waiting time: τ ~ Exp(a(y))
  3. Select reaction: k ~ DD(1,...,m, p1,...,pm)
  4. Update state: y ← y + vk

Technical Innovations

  1. Dimension-Independent Convergence: Monte Carlo convergence rate O(N^(-1/2)) is independent of dimension
  2. Adaptive Sampling: Importance sampling improves efficiency through appropriate proposal distribution selection
  3. Stochastic Differential Equation Solving: Euler-Maruyama method for solving diffusion processes
  4. MCMC Convergence: Ensures convergence to target distribution through detailed balance equations

Experimental Setup

Application Scenarios

  1. Radioactive Decay Model
    • Deterministic model: dy/dt = -λy(t)
    • Stochastic model: y →^λ z (Gillespie algorithm)
  2. SIR Epidemic Model
    • States: S (susceptible), I (infected), R (recovered)
    • Parameters: μ (birth-death rate), β (infection rate), γ (recovery rate)
  3. Financial Option Pricing
    • Geometric Brownian motion: dSt = μStdt + σStdWt
    • European call option: C0 = e^(-rT)Emax(ST-K, 0)

Evaluation Metrics

  1. Convergence Analysis: Error variation with sample size N
  2. Confidence Intervals: Error bounds at 95% probability
  3. Computational Efficiency: Algorithm runtime and memory usage
  4. Variance Comparison: Variance analysis across different sampling strategies

Experimental Results

Main Results

1. Monte Carlo Integration Convergence

  • Basic MC Method: Convergence rate O(N^(-0.5))
  • Importance Sampling: Significant precision improvement in rare event estimation
  • Example: When estimating Φ(-4.5), importance sampling achieves 3-4 orders of magnitude higher precision than basic MC

2. Stochastic Process Simulation

  • Brownian Particle: Expected time to hit boundary ≈ 0.4856 ± 0.0061
  • Gambler's Ruin: High consistency between theoretical and simulation results
  • Option Pricing: Black-Scholes model simulation result C0 ≈ 10.03 ± 0.29

3. MCMC Parameter Estimation

  • Recovery Rate Estimation: Posterior mean θ ≈ 0.1489 ± 0.0009
  • Portfolio Risk: Large loss probability ≈ 1.08%

Convergence Analysis

Monte Carlo Error Bounds: For estimator Y = (1/N)Σg(Xi):

  • Variance: Var(Y) = σ²/N
  • 95% Confidence interval: μ ± 1.96σ/√N

MCMC Diagnostics:

  • Burn-in period: Discard first 1000-2000 samples
  • Autocorrelation analysis: Ensure sufficient sample mixing

Historical Development

  1. Monte Carlo Origins: Invented by von Neumann and Ulam during World War II
  2. Metropolis Algorithm: Proposed by Metropolis et al. in 1953
  3. Hastings Extension: Hastings proposed asymmetric proposal distributions in 1970
  4. Gillespie Algorithm: Developed in 1977 for biochemical reaction network simulation

Theoretical Foundations

  • Law of Large Numbers: Guarantees consistency of Monte Carlo estimation
  • Central Limit Theorem: Provides asymptotic distribution of errors
  • Markov Chain Theory: Theoretical foundation for MCMC convergence

Conclusions and Discussion

Main Conclusions

  1. Method Applicability:
    • Deterministic methods suitable for large systems and predictable behavior
    • Stochastic methods suitable for small systems and uncertain environments
  2. Computational Efficiency:
    • Monte Carlo possesses advantages for high-dimensional problems
    • Importance sampling significantly improves rare event estimation precision
  3. Practical Value:
    • Provides complete algorithm implementation framework
    • Covers multiple important application domains

Limitations

  1. Convergence Speed: Monte Carlo methods converge slowly, requiring large sample sizes
  2. Variance Control: Variance may be large for certain problems, affecting estimation precision
  3. MCMC Diagnostics: Convergence diagnostics and burn-in period selection remain challenging

Future Directions

  1. Advanced MCMC Methods: Hamiltonian Monte Carlo, variational inference, etc.
  2. Parallel Algorithms: Leverage modern computing architectures for efficiency improvement
  3. Adaptive Methods: Dynamically adjust sampling strategies

In-Depth Evaluation

Strengths

  1. Educational Value:
    • Clear structure with progressive advancement from basics to advanced topics
    • Equal emphasis on theory and practice with complete code implementation
    • Covers multiple application domains with strong practical utility
  2. Technical Completeness:
    • Covers core stochastic simulation methods
    • Provides convergence analysis and error estimation
    • Includes modern MCMC methods
  3. Implementation Quality:
    • Well-structured Python code, easy to understand and use
    • Correct algorithm implementations, verified
    • Provides visualization results

Shortcomings

  1. Depth Limitations: As teaching material, certain advanced topics lack sufficient depth
  2. Modern Methods: Lacks recent variational inference and deep learning-related methods
  3. Computational Optimization: Limited discussion of parallel computing and GPU acceleration

Impact

  1. Educational Value: Provides high-quality resources for stochastic simulation teaching
  2. Practical Reference: Practical handbook for researchers and engineers
  3. Code Contribution: Provides reproducible algorithm implementations

Applicable Scenarios

  1. Teaching Purposes: Scientific computing, statistics, and applied mathematics courses
  2. Research Applications: Bioinformatics, financial engineering, physics simulation
  3. Engineering Practice: Risk assessment, system simulation, optimization problems

References

The lecture notes cite classical textbooks in the field:

  1. DeGroot & Schervish: Probability and Statistics
  2. Ross: Simulation
  3. Rubinstein & Kroese: Simulation and the Monte Carlo Method
  4. Robert & Casella: Monte Carlo Statistical Methods

Overall Assessment: This is a high-quality teaching material on stochastic simulation with strong systematicity and practical utility, providing learners with a complete learning pathway from theory to practice. While as teaching lecture notes it has certain limitations in cutting-edge methods, its educational and practical value are both high, making it an excellent reference resource in this field.