+ - 0:00:00
Notes for current slide
Notes for next slide

Uncertainty and Monte Carlo Simulation
BEE 4750/5750
Environmental Systems Analysis, Fall 2022


Vivek Srikrishnan
September 7, 2022
1 / 21

Outline


  1. Questions?
  2. Coding Example
  3. Introduction to Monte Carlo
2 / 21

Poll


Any questions?

URL: https://pollev.com/vsrikrish

Text: VSRIKRISH to 22333, then message

Poll Everywhere QR Code

3 / 21

Coding Example: CRUD Simulation


Now, let's do some simulations with the CRUD example.

Go to https://github.com/BEE4750/class-exercises and clone (you may have already done this).

If you've already cloned, make sure it's up to date with a git pull –- I made some changes over the weekend.

4 / 21

Monte Carlo Methods


Last week, we used Monte Carlo estimation for frequencies of sums of multiple dice.

5 / 21

Monte Carlo Methods


Monte Carlo estimation involves:

  1. Sampling input(s) from probability distribution(s);
  2. Simulating the quantity of interest;
  3. Aggregating the results.

James Bond in Casino Royale

6 / 21

Monte Carlo Methods


In this case, we used Monte Carlo to estimate a very simple quantity (which we didn't need it for), but it's a very powerful category of methods.

Monte Carlo estimation is a very useful method for calculating complex and high-dimensional integrals, since an integral is an nn-dimensional area:

  1. Sample uniformly from the domain;
  2. Compute how many samples are in the area of interest.
7 / 21

Monte Carlo (Formally)


We can formalize this common use of Monte Carlo estimation as the computation of the expected value of a random quantity YY:

μ=E[Y] \mu = \mathbb{E}[Y]

To do this, generate nn independent and identically distributed values Y1,,YnY_1, \ldots, Y_n. Then the sample estimate is

μ~=1ni=1nYi \tilde{\mu} = \frac{1}{n}\sum_{i=1}^n Y_i

8 / 21

Monte Carlo (Formally)


More generally, we want to compute some quantity Y=f(X)Y=f(X), where XX is distributed according to some probability distribution p(x)p(x) and f(x)f(x) is a real-valued function over a domain DD.

Then μ=E(Y)=Df(x)p(x)dx.\mu = \mathbb{E}(Y) = \int_D f(x)p(x)dx.

But the method is more general even than that: XX need not be continuous (like rolling dice).

And this isn't limited to scalars: so long as f(x)f(x) is sufficiently well-behaved, the law of large numbers ensures that Monte Carlo estimation will work.

9 / 21

The Large of Law Numbers


If

(1) YY is a random variable and its expectation exists and

(2) Y1,,YnY_1, \ldots, Y_n are independently and identically distributed

Then by the weak law of large numbers:

limnP(μ~nμε)=1 \lim_{n \to \infty} \mathbb{P}\left(\left|\tilde{\mu}_n - \mu\right| \leq \varepsilon \right) = 1

10 / 21

The Large of Law Numbers


If

(1) YY is a random variable and its expectation exists and

(2) Y1,,YnY_1, \ldots, Y_n are independently and identically distributed

Then by the weak law of large numbers:

limnP(μ~nμε)=1 \lim_{n \to \infty} \mathbb{P}\left(\left|\tilde{\mu}_n - \mu\right| \leq \varepsilon \right) = 1

In other words, eventually we will get within an arbitrary error of the true expectation. But how large is large enough?

11 / 21

Monte Carlo Sample Mean


Notice that the sample mean μ~n\tilde{\mu}_n is itself a random variable.

With some assumptions (the mean of YY exists and YY has finite variance), the Monte Carlo sample mean E[μ~n]\mathbb{E}[\tilde{\mu}_n] is

1ni=1nE[Yi]=1nnμ=μ \frac{1}{n}\sum_{i=1}^n \mathbb{E}[Y_i] = \frac{1}{n} n \mu = \mu

This means that the Monte Carlo estimate is an unbiased estimate of the mean.

12 / 21

Monte Carlo Sample Error


Next, we'd like to know more about the error of this estimate for a given sample size.

The variance of this estimator is

σ~n2=Var(μ~n)=E((μ~nμ)2)=σY2n \tilde{\sigma}_n^2 = \text{Var}\left(\tilde{\mu}_n\right) = \mathbb{E}\left((\tilde{\mu}_n - \mu)^2\right) = \frac{\sigma_Y^2}{n}

So as nn increases, the standard error decreases:

σ~n=σYn \tilde{\sigma}_n = \frac{\sigma_Y}{\sqrt{n}}

13 / 21

Monte Carlo Sample Error


In other words, if we want to decrease the Monte Carlo error by 10x, we need 100x additional samples. This is not an ideal method for high levels of accuracy.

Monte Carlo is an extremely bad method. It should only be used when all alternative methods are worse.

– Sokal, Monte Carlo Methods in Statistical Mechanics, 1996

14 / 21

Monte Carlo Sample Error


In other words, if we want to decrease the Monte Carlo error by 10x, we need 100x additional samples. This is not an ideal method for high levels of accuracy.

Monte Carlo is an extremely bad method. It should only be used when all alternative methods are worse.

– Sokal, Monte Carlo Methods in Statistical Mechanics, 1996

The thing is, though –- for a lot of problems, all alternative methods are worse!

15 / 21

Poll


When might we want to use Monte Carlo?

URL: https://pollev.com/vsrikrish

Text: VSRIKRISH to 22333, then message

Poll Everywhere QR Code

16 / 21

When To Use Monte Carlo?


Converging at a rate of 1/n1/\sqrt{n} is not great. But:

17 / 21

When To Use Monte Carlo?


Converging at a rate of 1/n1/\sqrt{n} is not great. But:

  • All models are wrong, and so there always exists some irreducible model error. Can we reduce the Monte Carlo error enough so it's less than the model error and other uncertainties?
18 / 21

When To Use Monte Carlo?


Converging at a rate of 1/n1/\sqrt{n} is not great. But:

  • All models are wrong, and so there always exists some irreducible model error. Can we reduce the Monte Carlo error enough so it's less than the model error and other uncertainties?
  • We often need a lot of simulations. Do we have enough computational power?
19 / 21

When To Use Monte Carlo?


If you can compute your answers analytically, you probably should. But for real problems, we often can't, and problems that are analytically tractable are often so stylized that we want to test them across a variety of uncertainties to make sure we didn't over-simplify.

20 / 21

Next Class


  • Monte Carlo confidence intervals
  • Correlated uncertainties
  • Intro to risk
21 / 21

Outline


  1. Questions?
  2. Coding Example
  3. Introduction to Monte Carlo
2 / 21
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow