Quant / Finance and numerics

Simulation and Excel

· Latest

Testing for fat tails, generating normal random numbers, exact vs Euler–Maruyama steps, and Monte Carlo pricing in a spreadsheet.

Definition / formulaKey factsSteps

36. How do I test for fat tails in Excel?

Definitions

Fat tails: more probability far from the mean than a normal with the same mean and variance. Measured by excess kurtosis >0>0 (Excel KURT returns excess kurtosis; a normal gives 0).

Key facts
  • A normal puts about 0.27% of mass beyond ±3\pm3 standard deviations.
  • Prices from Yahoo! Finance (slide 45).
Steps · build the sheet
  1. Column A: daily closes, oldest first.
  2. Column B: log returns =LN(A3/A2).
  3. =AVERAGE, =STDEV.S; column C: standardised returns =(B3-mean)/sd.
  4. =KURT(B:B): clearly above 0 means fat tails.
  5. Count ∣z∣>3|z|>3 with COUNTIF; compare with 0.27%.
  6. Histogram with FREQUENCY against NORM.DIST(x,0,1,FALSE); optional Q-Q plot against NORMSINV((i-0.5)/n).

37. How do I generate N(0,1)N(0,1) random numbers in Excel?

Two methods Lecture 1 notes, “Slow but accurate” and “Fast but inaccurate”
fast:  ϕ=12n(∑i=1nRAND()−n2)  (n=12: ∑i=112RAND()−6),slow:  NORMSINV(RAND()).\text{fast: }\ \phi=\sqrt{\frac{12}{n}}\Big(\sum_{i=1}^n\text{RAND}()-\frac n2\Big)\ \ \big(n=12:\ \textstyle\sum_{i=1}^{12}\text{RAND}()-6\big),\qquad \text{slow: }\ \text{NORMSINV(RAND())}.
Key facts
  • U∼U(0,1)U\sim U(0,1): E[U]=12\mathbb E[U]=\tfrac12, Var⁡[U]=112\operatorname{Var}[U]=\tfrac1{12}.
  • The fast method is only approximately normal (CLT), with tails cut at ±6\pm6.
  • Inverse transform: P(N−1(U)≤a)=P(U≤N(a))=N(a)P(N^{-1}(U)\le a)=P(U\le N(a))=N(a). Exact, but slower.
Steps · derive the fast scheme
  1. Mean of the sum is n/2n/2: subtract it.
  2. Variance is n/12n/12 by independence: scale by α\alpha with α2n/12=1\alpha^2n/12=1, α=12/n\alpha=\sqrt{12/n}.
  3. Normality by the Central Limit Theorem as n→∞n\to\infty.
  4. n=12n=12 makes α=1\alpha=1.

38. How do I simulate a path and price an exotic by Monte Carlo?

Exact step vs Euler–Maruyama Lecture 1 notes, “The random walk on a spreadsheet”

At each step draw a fresh ϕi∼N(0,1)\phi_i\sim N(0,1), so δXi=ϕiδt\delta X_i=\phi_i\sqrt{\delta t}. Euler–Maruyama (EM) replaces dtdt by δt\delta t and dXdX by ϕiδt\phi_i\sqrt{\delta t}; the exact step comes from the solved SDE.

GBM, dS=μS dt+σS dXdS=\mu S\,dt+\sigma S\,dXexact: Si+1=Siexp⁡((μ−12σ2)δt+σϕiδt),EM: Si+1=Si(1+μ δt+σϕiδt).\text{exact: } S_{i+1}=S_i\exp\Big(\big(\mu-\tfrac12\sigma^2\big)\delta t+\sigma\phi_i\sqrt{\delta t}\Big),\qquad \text{EM: } S_{i+1}=S_i\big(1+\mu\,\delta t+\sigma\phi_i\sqrt{\delta t}\big).Vasicek, dr=(η−γr) dt+σ dXdr=(\eta-\gamma r)\,dt+\sigma\,dX, rˉ=η/γ\bar r=\eta/\gammaexact: ri+1=rˉ+(ri−rˉ)e−γδt+σ1−e−2γδt2γ ϕi,EM: ri+1=ri+(η−γri) δt+σϕiδt.\text{exact: } r_{i+1}=\bar r+(r_i-\bar r)e^{-\gamma\delta t}+\sigma\sqrt{\frac{1-e^{-2\gamma\delta t}}{2\gamma}}\,\phi_i,\qquad \text{EM: } r_{i+1}=r_i+(\eta-\gamma r_i)\,\delta t+\sigma\phi_i\sqrt{\delta t}.

Pricing: simulate under the risk-neutral drift rr (not μ\mu), then V=e−rT payoff‾V=e^{-rT}\,\overline{\text{payoff}}.

Key facts
  • Lecture example: S0=100S_0=100, μ=0.1\mu=0.1, σ=0.2\sigma=0.2, δt=0.01\delta t=0.01, ϕ=0.12\phi=0.12 → 100.34; then ϕ=−0.25\phi=-0.25 → 99.94.
  • The exact steps have no discretisation error for any δt\delta t. EM is only accurate for small δt\delta t, and the GBM EM step can even go negative.
  • To compare the two schemes fairly, use the same ϕi\phi_i in both.
  • The exact Vasicek step comes from rt=rˉ+(r0−rˉ)e−γt+σ∫0teγ(s−t) dXsr_t=\bar r+(r_0-\bar r)e^{-\gamma t}+\sigma\int_0^te^{\gamma(s-t)}\,dX_s, whose variance follows from the Itô isometry.
  • Monte Carlo error falls like 1/paths1/\sqrt{\text{paths}}.
Steps · example: digital that pays 1 if M−A>0M-A>0 (MM = path maximum, AA = path average)
  1. Inputs in fixed cells: S0,r,σ,T,nS_0,r,\sigma,T,n, δt=T/n\delta t=T/n.
  2. One column per path, ϕ\phi from NORMSINV(RAND()), step with the risk-neutral scheme.
  3. Foot of column: =MAX(range), =AVERAGE(range), then =IF(M-A>0,1,0).
  4. Discount with EXP(-r*T); copy across many columns; average.
  5. Sanity check: M≥AM\ge A on every path, so almost every path pays 1 and the price is about e−rTe^{-rT}.
Jasmine Nguyen