A Practical Guide to Quantitative Finance Interviews
Contents
184

7.3 Numerical Methods

The prices of many financial instruments do not have closed-form analytical solutions. The valuation of these financial instruments relies on a variety of numerical methods. In this section, we discuss the application of Monte Carlo simulation and finite difference methods.

Monte Carlo simulation

Monte Carlo simulation is a method for iteratively evaluating a deterministic model using random numbers with appropriate probabilities as inputs. For derivative pricing, it simulates a large number of price paths of the underlying assets with probability corresponding to the underlying stochastic process (usually under risk-neutral measure), calculates the discounted payoff of the derivative for each path, and averages the discounted payoffs to yield the derivative price. The validity of Monte Carlo simulation relies on the law of large numbers.

Monte-Carlo simulation can be used to estimate derivative prices if the payoffs only depend on the final values of the underlying assets, and it can be adapted to estimate prices if the payoffs are path-dependent as well. Nevertheless, it cannot be directly applied to American options or any other derivatives with early exercise options.

A. Explain how you can use Monte Carlo simulation to price a European call option?

Solution: If we assume that stock price follows a geometric Brownian motion, we can simulate possible stock price paths. We can split the time between tt and TT into NN equally-spaced time steps.10 So Δt=T−tN\displaystyle\Delta t=\frac{T-t}{N} and ti=t+Δt×it_i=t+\Delta t\times i, for i=0,1,2,⋯ ,Ni=0,1,2,\cdots,N. We then simulate the stock price paths under risk-neutral probability using equation Si=Si−1e(r−σ2/2)(Δt)+σΔtεiS_i=S_{i-1}e^{(r-\sigma^2/2)(\Delta t)+\sigma\sqrt{\Delta t}\varepsilon_i}, where εi\varepsilon_i’s are IID random variables from standard normal distribution. Let’s say that we simulate MM paths and each one yields a stock price ST,kS_{T,k}, where k=1,2,⋯ ,Mk=1,2,\cdots,M, at maturity date TT.

185

The estimated price of the European call is the present value of the expected payoff, which can be calculated as C=e−r(T−t)∑k=1Mmax⁡(ST,k−K,0)M\displaystyle C=e^{-r(T-t)}\frac{\sum_{k=1}^M\max(S_{T,k}-K,0)}{M}.

B. How do you generate random variables that follow N(μ,σ2)N(\mu,\sigma^2) (normal distribution with mean μ\mu and variance σ2\sigma^2) if your computer can only generate random variables that follow continuous uniform distribution between 0 and 1?

Solution: This is a great question to test the basic knowledge of random number generation, the foundation of Monte Carlo simulation. The solution to this question can be dissected to two steps:

  1. Generate random variable of x∼N(0,1)x\sim N(0,1) from uniform random number generator using inverse transform method and rejection method.
  2. Scale xx to μ+σx\mu+\sigma x to generate the final random variables that follow N(μ,σ2)N(\mu,\sigma^2).

The second step is straightforward; the first step deserves some explanations. A popular approach to generating random variables is the inverse transform method: For any continuous random variable XX with cumulative density function FF (U=F(X)U=F(X)), the random variable XX can be defined as the inverse function of U: X=F−1(U), 0≤U≤1X=F^{-1}(U),\ 0\le U\le1. It is obvious that X=F−1(U)X=F^{-1}(U) is a one-to-one function with 0≤U≤10\le U\le1. So any continuous random variable can be generated using the following process:

For this model to work, F−1(U)F^{-1}(U) must be computable. For standard normal distribution, U=F(X)=∫−∞X12πe−x2/2dx\displaystyle U=F(X)=\int_{-\infty}^X\frac{1}{\sqrt{2\pi}}e^{-x^2/2}dx. The inverse function has no analytical solution. Theoretically, we can come up with the one-to-one mapping of XX to UU as the numeric solution of ordinary differential equation F′(x)=f(x)=12πe−x2/2\displaystyle F'(x)=f(x)=\frac{1}{\sqrt{2\pi}}e^{-x^2/2} using numerical integration method such as the Euler method.11 Yet this approach is less efficient than the rejection method:

186

Some random variables have pdf f(x)f(x), but no analytical solution for F−1(U)F^{-1}(U). In these cases, we can use a random variable with pdf g(y)g(y) and Y=G−1(U)Y=G^{-1}(U) to help generate random variables with pdf f(x)f(x). Assume that MM is a constant such that f(y)g(y)≤M, ∀y\displaystyle\frac{f(y)}{g(y)}\le M,\ \forall y. We can implement the following acceptance-rejection method:

An exponential random variable (g(x)=λe−λxg(x)=\lambda e^{-\lambda x}) with λ=1\lambda=1 has cdf u=G(x)=1−e−xu=G(x)=1-e^{-x}. So the inverse function has analytical solution x=−log⁡(1−u)x=-\log(1-u) and a random variable with exponential distribution can be conveniently simulated. For standard normal distribution, f(x)=12πe−x2/2\displaystyle f(x)=\frac{1}{\sqrt{2\pi}}e^{-x^2/2},

f(x)g(x)=2πex−x2/2<2πe−(x−1)2/2+1/2≤2πe1/2≈1.32, ∀0<x<∞\frac{f(x)}{g(x)}=\sqrt{\frac2\pi}e^{x-x^2/2}\lt\sqrt{\frac2\pi}e^{-(x-1)^2/2+1/2}\le\sqrt{\frac2\pi}e^{1/2}\approx1.32,\ \forall0\lt x\lt\infty

So we can choose M=1.32M=1.32 and use the acceptance-rejection method to generate x∼N(0,1)x\sim N(0,1) random variables and scale them to N(μ,σ2)N(\mu,\sigma^2) random variables.

C. Can you explain a few variance reduction techniques to improve the efficiency of Monte Carlo simulation?

Solution: Monte Carlo simulation, in its basic form, is the mean of IID random variables Y1,Y2,⋯ ,YM: Y‾=1M∑i=1MYiY_1,Y_2,\cdots,Y_M:\ \displaystyle\overline Y=\frac1M\sum_{i=1}^MY_i. Since the expected value of each YiY_i is unbiased, the estimator Y‾\overline Y is unbiased as well. If Var⁡(Y)=σ\operatorname{Var}(Y)=\sigma and we generate IID YiY_i, then Var⁡(Y‾)=σ/M\operatorname{Var}(\overline Y)=\sigma/\sqrt M, where MM is the number of simulations. Not surprisingly, Monte Carlo 187 simulation is computationally intensive if σ\sigma is large. Thousands or even millions of simulations are often required to get the desired accuracy. Depending on the specific problems, a variety of methods have been applied to reduce variance.

Antithetic variable: For each series of εi\varepsilon_i’s, calculate its corresponding payoff Y(ε1,⋯ ,εN)Y(\varepsilon_1,\cdots,\varepsilon_N). Then reverse the sign of all εi\varepsilon_i’s and calculate the corresponding payoff Y(−ε1,⋯ ,−εN)Y(-\varepsilon_1,\cdots,-\varepsilon_N). When Y(ε1,⋯ ,εN)Y(\varepsilon_1,\cdots,\varepsilon_N) and Y(−ε1,⋯ ,−εN)Y(-\varepsilon_1,\cdots,-\varepsilon_N) are negatively correlated, the variance is reduced.

Moment matching: Specific samples of the random variable may not match the population distribution well. We can draw a large set of samples first and then rescale the samples to make the samples’ moments (mean and variance are the most commonly used) match the desired population moments.

Control variate: If we want to price a derivative XX and there is a closely related derivative YY that has an analytical solution, we can generate a series of random numbers and use the same random sequences to price both XX and YY to yield X^\hat X and Y^\hat Y. Then XX can be estimated as X^+(Y−Y^)\hat X+(Y-\hat Y). Essentially we use (Y−Y^)(Y-\hat Y) to correct the estimation error of X^\hat X.

Importance sampling: To estimate the expected value of h(x)h(x) from distribution f(x)f(x), instead of drawing xx from distribution f(x)f(x), we can draw xx from distribution g(x)g(x) and use Monte Carlo simulation to estimate expected value of h(x)f(x)g(x)\displaystyle\frac{h(x)f(x)}{g(x)}:

Ef(x)[h(x)]=∫h(x)f(x)dx=∫h(x)f(x)g(x)g(x)dx=Eg(x)[h(x)f(x)g(x)].\displaystyle E_{f(x)}[h(x)]=\int h(x)f(x)dx=\int\frac{h(x)f(x)}{g(x)}g(x)dx=E_{g(x)}\left[\frac{h(x)f(x)}{g(x)}\right].13

If h(x)f(x)g(x)\displaystyle\frac{h(x)f(x)}{g(x)} has a smaller variance than h(x)h(x), then importance sampling can result in a more efficient estimator. This method is better explained using a deep out-of-the-money option as an example. If we directly use risk-neutral f(ST)f(S_T) as the distribution, most of the simulated paths will yield h(ST)=0h(S_T)=0 and as a result the estimation variance will be large. If we introduce a distribution g(ST)g(S_T) that has much wider span (fatter tail for STS_T), more simulated paths will have positive h(ST)h(S_T). The scaling factor f(x)g(x)\frac{f(x)}{g(x)} will keep the estimator unbiased, but the approach will have lower variance.

188

Low-discrepancy sequence: Instead of using random samples, we can generate a deterministic sequence of “random variable” that represents the distribution. Such low-discrepancy sequences may make the convergence rate 1/M1/M.

D. If there is no closed-form pricing formula for an option, how would you estimate its delta and gamma?

Solution: As we have discussed in problem A, the prices of options with or without closed-form pricing formulas can be derived using Monte Carlo simulation. The same methods can also be used to estimate delta and gamma by slightly changing the current underlying price from SS to S±δSS\pm\delta S, where δS\delta S is a small positive value. Run Monte Carlo simulation for all three starting prices S−δSS-\delta S, SS and S+δSS+\delta S, we will get their corresponding option prices f(S−δS)f(S-\delta S), f(S)f(S) and f(S+δS)f(S+\delta S).

Estimated delta: Δ=δfδS=f(S+δS)−f(S−δS)2δS\displaystyle\Delta=\frac{\delta f}{\delta S}=\frac{f(S+\delta S)-f(S-\delta S)}{2\delta S}

Estimated gamma: Γ=(f(S+δS)−f(S))−(f(S)−f(S−δS))δS2\displaystyle\Gamma=\frac{(f(S+\delta S)-f(S))-(f(S)-f(S-\delta S))}{\delta S^2}

To reduce variance, it’s often better to use the same random number sequences to estimate f(S−δS)f(S-\delta S), f(S)f(S) and f(S+δS)f(S+\delta S).14

E. How do you use Monte Carlo simulation to estimate π\pi?

Solution: Estimation of π\pi is a classic example of Monte Carlo simulation. One standard method to estimate π\pi is to randomly select points in the unit square (xx and yy are independent uniform random variables between 0 and 1) and determine the ratio of points that are within the circle x2+y2≤1x^2+y^2\le1. For simplicity, we focus on the first quadrant. As shown in Figure 7.1, any points within the circle satisfy the equation xi2+yi2≤1x_i^2+y_i^2\le1. The percentage of the points within the circle is proportional to its area:

p^=Number of (xi,yi) within xi2+yi2≤1Number of (xi,yi) within the square=1/4π1×1=14π⇒π^=4p^.\hat p=\frac{\text{Number of }(x_i,y_i)\text{ within }x_i^2+y_i^2\le1}{\text{Number of }(x_i,y_i)\text{ within the square}}=\frac{1/4\pi}{1\times1}=\frac14\pi\Rightarrow\hat\pi=4\hat p.

So we generate a large number of independent (x,y)(x,y) points, estimate the ratio of the points within the circle to the points in the square, and multiply the ratio by 4 to yield an estimation of π\pi. Figure 7.1 uses only 1000 points for illustration. With today’s 189 computing power, we can easily generate millions of (x,y)(x,y) pairs to estimate π\pi with good precision. 1,000 simulations with 1,000,000 (x,y)(x,y) points each using Matlab took less than 1 minute on a laptop and gave an average estimation of π\pi as 3.1416 with standard deviation 0.0015.

One thousand randomly sampled points in the unit square, with a quarter-circle boundary separating points satisfying x squared plus y squared at most one.
Figure 7.1 A Monte Carlo simulation method to estimate π\pi

Finite difference method

The finite difference method is another popular numerical technique for derivative pricing. It numerically solves a differential equation to estimate the price of a derivative by discretizing the time and the price of the underlying security. We can convert the Black-Scholes-Merton equation, a second order nonlinear partial differential equation, to a heat diffusion equation (as we did in Chapter 6). This new equation, expressed as a function of τ\tau (time to maturity) and xx (a function of the price of the underlying security), is a general differential equation for derivatives. The difference between various derivatives lies in the boundary conditions. By building a grid of xx and τ\tau and using the boundary conditions, we can recursively calculate uu at every xx and τ\tau using finite difference methods.

A. Can you briefly explain finite difference methods?

Solution: There are several version of finite difference methods used in practice. Let’s briefly go over the explicit difference method, the implicit difference method and the 190 Crank-Nicolson method. As shown in Figure 7.2, if we divide the range of τ\tau, [0,T][0,T], into NN discrete intervals with increment Δτ=T/N\Delta\tau=T/N and divide the range of xx, [x0,xJ][x_0,x_J], into JJ discrete intervals with increment Δx=(xJ−x0)/J\Delta x=(x_J-x_0)/J, the time τ\tau and the space of xx can be expressed as a grid of τn, n=1,⋯ ,N\tau_n,\ n=1,\cdots,N and xj, j=1,⋯ ,Jx_j,\ j=1,\cdots,J.

A space-time grid with vertical coordinate x and horizontal coordinate tau. The three levels x j minus1, x j, and x j plus1 at times tau n and tau n plus1 show the explicit and implicit difference stencils.
Figure 7.2 Grid of τ\tau and xx for finite different methods

The explicit difference method uses the forward difference at time τn\tau_n and the second-order central difference at xjx_j:

∂u∂τ≈ujn+1−ujnΔτ=uj+1n−2ujn+uj−1n(Δx)2≈∂2u∂x2.\frac{\partial u}{\partial\tau}\approx\frac{u_j^{n+1}-u_j^n}{\Delta\tau}=\frac{u_{j+1}^n-2u_j^n+u_{j-1}^n}{(\Delta x)^2}\approx\frac{\partial^2u}{\partial x^2}.

Rearranging terms, we can express ujn+1u_j^{n+1} as a linear combination of uj+1nu_{j+1}^n, ujnu_j^n and uj−1nu_{j-1}^n: ujn+1=αuj−1n+(1−2α)ujn+αuj+1nu_j^{n+1}=\alpha u_{j-1}^n+(1-2\alpha)u_j^n+\alpha u_{j+1}^n, where α=Δt/(Δx)2\alpha=\Delta t/(\Delta x)^2. Besides, we often have boundary conditions uj0u_j^0, u0nu_0^n, and uJnu_J^n for all n=1,⋯ ,N; j=0,⋯ ,Jn=1,\cdots,N;\ j=0,\cdots,J. Combining the boundary 191 conditions and equation ujn+1=αuj−1n+(1−2α)ujn+αuj+1nu_j^{n+1}=\alpha u_{j-1}^n+(1-2\alpha)u_j^n+\alpha u_{j+1}^n, we can estimate all ujnu_j^n’s on the grid.

The implicit difference method uses the backward difference at time tn+1t_{n+1} and the second-order central difference at xjx_j:

∂u∂τ≈ujn+1−ujnΔτ=uj+1n+1−2ujn+1+uj−1n+1(Δx)2≈∂2u∂x2.\frac{\partial u}{\partial\tau}\approx\frac{u_j^{n+1}-u_j^n}{\Delta\tau}=\frac{u_{j+1}^{n+1}-2u_j^{n+1}+u_{j-1}^{n+1}}{(\Delta x)^2}\approx\frac{\partial^2u}{\partial x^2}.

The Crank-Nicolson method uses the central difference at time (tn+tn+1)/2(t_n+t_{n+1})/2 and the second-order central difference at xjx_j:

∂u∂τ≈ujn+1−ujnΔτ=12(uj+1n−2ujn+uj−1n(Δx)2+uj+1n+1−2ujn+1+uj−1n+1(Δx)2)≈∂2u∂x2.\frac{\partial u}{\partial\tau}\approx\frac{u_j^{n+1}-u_j^n}{\Delta\tau}=\frac12\left(\frac{u_{j+1}^n-2u_j^n+u_{j-1}^n}{(\Delta x)^2}+\frac{u_{j+1}^{n+1}-2u_j^{n+1}+u_{j-1}^{n+1}}{(\Delta x)^2}\right)\approx\frac{\partial^2u}{\partial x^2}.

B. If you are solving a parabolic partial differential equation using the explicit finite difference method, is it worse to have too many steps in the time dimension or too many steps in the space dimension?

Solution: The equation for ujn+1u_j^{n+1} in the explicit finite difference method is ujn+1=αuj−1n+(1−2α)ujn+αuj+1nu_j^{n+1}=\alpha u_{j-1}^n+(1-2\alpha)u_j^n+\alpha u_{j+1}^n, where α=Δt/(Δx)2\alpha=\Delta t/(\Delta x)^2. For the explicit finite difference method to be stable, we need to have 1−2α>0⇒Δt/(Δx)2<1/21-2\alpha>0\Rightarrow\Delta t/(\Delta x)^2\lt1/2. So a small Δt\Delta t (i.e., many time steps) is desirable, but a small Δx\Delta x (too many space steps) may make Δt/(Δx)2>1/2\Delta t/(\Delta x)^2>1/2 and the results unstable. In that sense, it is worse to have too many steps in the space dimension. In contrast, the implicit difference method is always stable and convergent.