# Lecture 008

## Numerical Integration

The basic idea is: as dimension increase, you need more sample points. So only Monte Carlo can save us.

Desired Properties of Uniform Random:

• sequence should pass statistical tests of randomness

• sequence should have a long period

• efficient to compute, requires only little storage

• repeatability: always produce the same sequence (different compilers, operating systems, processors)

Modern example is PCG32 (pcg-random.org)

But estimating with average of random sample will give us wrong estimation.

Solution: Approximate $f$ by averaging realizations of a random variable $X$, and explicitly accounting for its PDF:

F \simeq \frac{1}{N} \sum_{i = 1}^N \frac{f(x_i)}{p(x_i)}

// TODO: code

Pros

• Flexible

• Easy to implement

• Easily handles complex integrands

• Efficient for high dimensional integrands

• Unbiased estimator

Cons

• Variance (noise)

• Slow convergence ($O(\frac{1}{\sqrt{N}})$)

## Monte Carlo Sampling by Choosing $p(x)$

Rejection Sampling:

• flexible: good for complex shape

• inefficient for small area

• difficult to combine with stratification (quasi-Monte Carlo)

// TODO: finish this

Table of Content