σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
Hidden Markov Models skill›Module 3 · Regimes in markets›Topic 3.1·~55 minAdvanced

Gaussian emissions for returns

Skill positionModule 3 of 3 · Topic 1 of 4
3.1 Gaussian emissions for returns
—Lab score— / 100Total XP—Streak—

From size classes to real returns

Real returns are not Small or Large, they are numbers like −3.0%-3.0\%−3.0% or +0.4%+0.4\%+0.4%. So the emission of each state becomes a bell curve: in state jjj the return is normal with its own mean μj\mu_jμj​ and standard deviation σj\sigma_jσj​. The emission probability Bj(r)B_j(r)Bj​(r) is the height of that curve at the observed return rrr. Everything else in the algorithms stays the same: forward, Viterbi, forward-backward and Baum-Welch only ask for the numbers Bj(ot)B_j(o_t)Bj​(ot​). In the M-step the new μj\mu_jμj​ and σj\sigma_jσj​ are the weighted mean and weighted standard deviation of the returns, with the smoothed probabilities γt(j)\gamma_t(j)γt​(j) as weights.

Bj(r)=1σj2πexp⁡ ⁣(−(r−μj)22σj2),μj=∑tγt(j)rt∑tγt(j),σj2=∑tγt(j)(rt−μj)2∑tγt(j)B_j(r)=\frac{1}{\sigma_j\sqrt{2\pi}}\exp\!\Big(-\frac{(r-\mu_j)^{2}}{2\sigma_j^{2}}\Big),\qquad \mu_j=\frac{\sum_t\gamma_t(j)r_t}{\sum_t\gamma_t(j)},\qquad \sigma_j^{2}=\frac{\sum_t\gamma_t(j)(r_t-\mu_j)^{2}}{\sum_t\gamma_t(j)}Bj​(r)=σj​2π​1​exp(−2σj2​(r−μj​)2​),μj​=∑t​γt​(j)∑t​γt​(j)rt​​,σj2​=∑t​γt​(j)∑t​γt​(j)(rt​−μj​)2​(1)

A model with a calm and a stormy state is a mixture of two normal curves. Each curve alone has thin tails, but the mixture has fat tails: the stormy state, with its large σ\sigmaσ, produces big moves far more often than a single normal curve with the average volatility would. This is one reason HMMs fit real returns well. The states also tell a story. Typically one finds a calm state with a small positive mean and low volatility, and a stormy state with a negative mean and high volatility, and the stormy state is sticky, so crashes arrive in clusters.

A -3% dayLet Calm have mean +0.05%+0.05\%+0.05% and standard deviation 0.6%0.6\%0.6%, and Stormy mean −0.10%-0.10\%−0.10% and standard deviation 2.0%2.0\%2.0% a day. A return of −3%-3\%−3% is (−3−0.05)/0.6=−5.1(-3-0.05)/0.6=-5.1(−3−0.05)/0.6=−5.1 standard deviations from Calm but only (−3+0.10)/2=−1.45(-3+0.10)/2=-1.45(−3+0.10)/2=−1.45 from Stormy. The curve heights are 1.6×10−61.6\times10^{-6}1.6×10−6 for Calm and 0.06970.06970.0697 for Stormy. With a prior of 0.90.90.9 for Calm and 0.10.10.1 for Stormy, the posterior chance of Stormy is 0.1×0.0697 / (0.1×0.0697+0.9×1.6×10−6)=0.99980.1\times0.0697\,/\,(0.1\times0.0697+0.9\times1.6\times10^{-6})=0.99980.1×0.0697/(0.1×0.0697+0.9×1.6×10−6)=0.9998. A daily volatility of 2%2\%2% is 2%×252=31.7%2\%\times\sqrt{252}=31.7\%2%×252​=31.7% a year.
  • Gaussian emission: in each state the return is normal with its own mean and volatility.
  • M-step for returns: weighted mean and weighted standard deviation, with γt(j)\gamma_t(j)γt​(j) as weights.
  • Fat tails for free: a mixture of calm and stormy normals has heavier tails than one normal.

Lab · what's graded

  • A z-score15 pts
  • A curve height15 pts
  • An annual volatility15 pts
  • Which state was it?15 pts
  • Why a mixture has fat tails10 pts
  • Match the symbols15 pts
  • What the stormy state is15 pts
0/ 7 answered
Tasks
1Numeric answer15 ptsNot answered

Stormy has mean −0.10%-0.10\%−0.10% and standard deviation 2.0%2.0\%2.0%. How many standard deviations from its mean is a return of −3%-3\%−3%, z=(−3−(−0.10))/2.0z=(-3-(-0.10))/2.0z=(−3−(−0.10))/2.0? Give two decimals.

z=z =z=accepted: ± 0.01
2Numeric answer15 ptsNot answered

What is the height of the Stormy curve at that return, exp⁡(−z2/2) / (σ2π)\exp(-z^{2}/2)\,/\,(\sigma\sqrt{2\pi})exp(−z2/2)/(σ2π​) with z=−1.45z=-1.45z=−1.45 and σ=2.0\sigma=2.0σ=2.0? Give four decimals.

b=b =b=accepted: ± 0.0004
3Numeric answer15 ptsNot answered

The stormy state has a daily volatility of 2.0%2.0\%2.0%. What is its annual volatility, 2.0×2522.0\times\sqrt{252}2.0×252​, in percent? Give one decimal.

v=v =v=accepted: ± 0.1
4Numeric answer15 ptsNot answered

With prior 0.90.90.9 for Calm and 0.10.10.1 for Stormy, curve heights 1.6×10−61.6\times10^{-6}1.6×10−6 (Calm) and 0.06970.06970.0697 (Stormy), what is the posterior chance of Stormy, 0.1×0.06970.1×0.0697+0.9×1.6×10−6\dfrac{0.1\times0.0697}{0.1\times0.0697+0.9\times1.6\times10^{-6}}0.1×0.0697+0.9×1.6×10−60.1×0.0697​? Give four decimals.

p=p =p=accepted: ± 0.0003
5Choice10 ptsNot answered

Why does a mixture of a calm and a stormy normal curve have fatter tails than one normal curve with the average volatility?

6Match15 ptsNot answered

Match each symbol with its meaning.

Pick the partner of each item on the left.

μj\mu_jμj​
σj\sigma_jσj​
Bj(r)B_j(r)Bj​(r)
γt(j)\gamma_t(j)γt​(j)
7Explain in words15 ptsNot answered

In one or two sentences, explain why a mixture of a calm and a stormy normal curve produces fat tails.

Math modeKeyboard or LaTeX inputTask 1 of 7 · Ctrl ⏎ to check

Log in to run your code.

Every lecture is free to read. Create an account or log in to run code, run tests and submit this lab.

  • In-browser IDE with a bash terminal — nothing to install
  • Instant grading, XP and your place on the skill
Create an accountLog in
OR
Continue with GitHub