MTH3007b Lecture 7

Me, in the lecture

zzzzz…

This session covers two distinct but related threads: Monte Carlo integration as a numerical quadrature technique, and stochastic processes starting with the random walk and building up to the Ornstein-Uhlenbeck process. Both rely heavily on the machinery of pseudo-random number generation.

Monte Carlo Integration

Monte Carlo integration estimates a definite integral by sampling the integrand at random points rather than at a regular grid.

Pseudo-Random Numbers

Pseudo-random numbers are generated deterministically by an algorithm but pass statistical tests for randomness. In Python, numpy.random provides a uniform distribution on via np.random.uniform(a, b, N).

A seed fixes the starting point of the random number generator, giving reproducible results:

Python
Output

Gaussian (normal) random numbers with mean and standard deviation are generated by np.random.normal(mu, sigma, N).

1D Integration

To estimate , draw uniform samples and compute:

where is the sample mean. The error on this estimate is:

The error scales as , so quadrupling the number of samples halves the error.

Higher-Dimensional Integration

For an integral over a -dimensional hypervolume :

The error is still , regardless of the dimension . This is the key advantage of Monte Carlo over grid-based quadrature, which degrades as dimension increases.

Example: Integrating on

Python
Output

The exact answer is .

Stochastic Processes

Discrete Random Walk

The random walk is the simplest discrete stochastic process. At each step, a particle moves or with equal probability:

The Wiener Process

The Wiener process is the continuous-time limit of the random walk. It satisfies:

  • for
  • Increments over non-overlapping intervals are independent

The numerical Euler-Maruyama scheme for the Wiener process is:

where .

Python
Output

The Ornstein-Uhlenbeck Process

The Ornstein-Uhlenbeck process (OU process) adds a linear restoring force. The continuous equation is:

The numerical update rule is:

Python
Output

The Langevin Equation

The Langevin equation is the physical framing of the OU process:

where is white noise with the correlation:

Numerically, the white noise term is approximated as , which recovers the OU update rule above.


Pre-Lecture Notes from University Notes

  • Monte Carlo integration: with error .
  • Error is regardless of dimension - decisive advantage over grid-based methods in high dimensions.
  • np.random.seed(0) for reproducibility; np.random.uniform(a,b,N) for uniform samples.
  • Wiener process: , increments , independent increments.
  • Euler-Maruyama update: , .
  • OU process: ; update .
  • Langevin: with ; numerically .
  • Next session: Dirac delta initial conditions for the diffusion equation, and first-passage time problems.