2023-08-14

Random variables

  • Life is filled with heterogeneity and uncertainty.
  • Our model also must account for this.
    • Agents of different types distributed in some way.
    • Agents are hit with shocks that affect decisions and outcomes.
  • We often want to calculate statistics that depend on this randomness:
    • Expected Continutation Values.
    • Probability of making a given decision.
  • Problem:
    1. Distributions often don’t have simple closed form solutions.
    2. Calculations of these statistics can be challenging.

Solution

  • Let our computers calculate numeric approximations of these values.
  • We can do this by performing simulations from the known random distribution.

Example - Birthday Problem

  • Question: If there are N people in a room, what is the probability that at least two of them share the same birthday?
    • Assume all days are equally likely.
    • Ignore leap years.
  • Closed form expression exists, but is a messy combination of binomials.
  • Can perform simulations to arrive at a good approximation.

Example - Distance of Points in a Cube

  • Question: If two points are chosen at random within the uniform cube, what is the average distance between them?

  • Close form solution is an integral in six dimensions: \[ \tiny E[D] = \int_0^1\int_0^1\int_0^1\int_0^1\int_0^1\int_0^1\sqrt{(x_1-y_1)^2+(x_2-y_2)^2+(x_3-y_3)^2)}dx_1dx_2dx_3dy_1dy_2dy_3 \]

  • Much quicker to perform some simulations to get a good approximation.

Economic Example: College Choice

  • In period 1, individual chooses to go to college based on expected value: \[ V_1 = \max_{s \in \{0,1\}} \textbf{E}_\epsilon[V_2(s,\epsilon)] \] In period 2, agent chooses whether to supply labor: \[ V_2(s) = \max_{s \in \{0,1\}} \log(c) + \alpha (1-\ell) \] \[ c = \begin{cases} B, \:\:\: \ell = 0 \\ \exp(\beta_0 + \beta_1 s + \epsilon), \:\:\: \ell = 1 \end{cases} \] \[ \epsilon \sim N(0,\sigma) \]

Why is this hard?

  • We need to know the expected continuation value: \[ V_1 = \max_{s \in \{0,1\}} \textbf{E}_\epsilon[V_2(s,\epsilon)] \]
  • Shock \(\epsilon\) will effect our wage and whether we decide to work our not.
    • If \(\epsilon\) is low, we will decide not to work.
  • Need to solve for the cut-off value \(\epsilon\) for each schooling decision, and then take a conditional expectation.
  • Or we can just ask our computer to do some simulations to approximate the expectation.

Non-random sequences

  • Simulating random numbers can be a good way to approximate expectations.

  • But requires a large number of simulations to obtain good coverage of the distribution.

  • Non-random sequences can obtain better coverage of the distribution.

  • Ex: Halton sequence with base 2:

    • 1/2, 1/4, 3/4, 1/8, 5/8, 3/8, 7/8, 1/16, 9/16, …
  • Ex: Halton sequence with base 3:

    • 1/3, 2/3, 1/9, 4/9, 7/9, 2/9, 5/9, 8/9, 1/27, …
  • The Halton sequence will appear to be random for many purposes.

Simulating from Uniform Square

Quadrature: Approximating Integrals

  • We are interested in approximating an integral (such as an expectation):

\[ \int_a^b g(x)dx. \] - To do this, we choose a set of n nodes (\(x_i\)) and weights (\(w_i\)) and calculate: \[ \sum_i^n w_i g(x_i) \approx \int_a^b g(x)dx. \] - How do we best choose the weights and nodes? Ask Gauss

Quadrature Examples

  • Choice of \((w_i, x_i)\) depends on the integral:
  • Gauss-Legendre Quadrature: \[ \int_{-1}^1 g(x) dx. \]
  • Gauss-Hermite Quadrature: Good for normal distribution. \[ \int_{-\infty}^\infty f(x) \exp(-x^2) dx. \]
  • FastGaussQuadrature.jl provides nodes and weights.