σμ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 2 · The core algorithms›Topic 2.3·~55 minAdvanced

Forward-backward smoothing

Skill positionModule 2 of 3 · Topic 3 of 4
2.3 Forward-backward smoothing
—Lab score— / 100Total XP—Streak—

Looking back with hindsight

The forward algorithm gives filtered probabilities: our belief about day ttt using only the data up to day ttt. After we have the whole history we can do better for the past. If day one looked calm but days two and three had large moves, those later days tell us something about day one. Smoothing uses all the data. It needs a second quantity βt(i)\beta_t(i)βt​(i): the probability of the observations after day ttt, given that day ttt is in state iii. We compute it backward, starting from βT=1\beta_T=1βT​=1.

βT(i)=1,βt(i)=∑jAijBj(ot+1)βt+1(j),γt(i)=αt(i)βt(i)∑kαt(k)βt(k)\beta_T(i)=1,\qquad \beta_t(i)=\sum_jA_{ij}B_j(o_{t+1})\beta_{t+1}(j),\qquad \gamma_t(i)=\frac{\alpha_t(i)\beta_t(i)}{\sum_k\alpha_t(k)\beta_t(k)}βT​(i)=1,βt​(i)=j∑​Aij​Bj​(ot+1​)βt+1​(j),γt​(i)=∑k​αt​(k)βt​(k)αt​(i)βt​(i)​(1)

The product αt(i)βt(i)\alpha_t(i)\beta_t(i)αt​(i)βt​(i) is the probability of all the data together with being in state iii on day ttt: α\alphaα covers the past and today, β\betaβ covers the future. Dividing by the sum over states gives the smoothed probability γt(i)\gamma_t(i)γt​(i), the belief about day ttt given the whole sample. Summing αtβt\alpha_t\beta_tαt​βt​ over the states gives the same number for every ttt, the probability of the data. Smoothed probabilities are the right tool to describe the past, for example to label historical regimes. They are the wrong tool to trade on, because on the day itself the future is not known.

Day one with hindsightFor Small, Large, Large: β3=(1, 1)\beta_3=(1,\ 1)β3​=(1, 1). Then β2(C)=0.9⋅0.1+0.1⋅0.7=0.16\beta_2(C)=0.9\cdot0.1+0.1\cdot0.7=0.16β2​(C)=0.9⋅0.1+0.1⋅0.7=0.16 and β2(S)=0.2⋅0.1+0.8⋅0.7=0.58\beta_2(S)=0.2\cdot0.1+0.8\cdot0.7=0.58β2​(S)=0.2⋅0.1+0.8⋅0.7=0.58. Next β1(C)=0.9⋅0.1⋅0.16+0.1⋅0.7⋅0.58=0.055\beta_1(C)=0.9\cdot0.1\cdot0.16+0.1\cdot0.7\cdot0.58=0.055β1​(C)=0.9⋅0.1⋅0.16+0.1⋅0.7⋅0.58=0.055 and β1(S)=0.2⋅0.1⋅0.16+0.8⋅0.7⋅0.58=0.328\beta_1(S)=0.2\cdot0.1\cdot0.16+0.8\cdot0.7\cdot0.58=0.328β1​(S)=0.2⋅0.1⋅0.16+0.8⋅0.7⋅0.58=0.328. With α1=(0.54, 0.12)\alpha_1=(0.54,\ 0.12)α1​=(0.54, 0.12): α1β1=(0.0297, 0.0394)\alpha_1\beta_1=(0.0297,\ 0.0394)α1​β1​=(0.0297, 0.0394), which add to 0.06910.06910.0691, the probability of the data. So the smoothed chance of Calm on day one is 0.0297/0.0691=0.430.0297/0.0691=0.430.0297/0.0691=0.43, down from the filtered 0.820.820.82. The two large moves that came after changed our mind.
  • Backward values βt(i)\beta_t(i)βt​(i): the chance of all later observations given the state on day ttt.
  • Smoothing γt∝αtβt\gamma_t\propto\alpha_t\beta_tγt​∝αt​βt​: the belief about day ttt given all the data, past and future.
  • For describing the past only: smoothed probabilities use future data, so they cannot be used to trade.

Lab · what's graded

  • A backward value15 pts
  • Another backward value15 pts
  • The smoothed chance of stormy15 pts
  • A check on the sum10 pts
  • Filtered versus smoothed10 pts
  • What smoothing adds10 pts
  • Match the vocabulary10 pts
  • Why smoothed and filtered differ15 pts
0/ 8 answered
Tasks
1Numeric answer15 ptsNot answered

With β3=(1, 1)\beta_3=(1,\ 1)β3​=(1, 1) and a large move on day 3, what is β2(S)=ASCBC(g)+ASSBS(g)\beta_2(S)=A_{SC}B_C(g)+A_{SS}B_S(g)β2​(S)=ASC​BC​(g)+ASS​BS​(g) with 0.2⋅0.1+0.8⋅0.70.2\cdot0.1+0.8\cdot0.70.2⋅0.1+0.8⋅0.7?

b=b =b=accepted: ± 0.005
2Numeric answer15 ptsNot answered

With β2=(0.16, 0.58)\beta_2=(0.16,\ 0.58)β2​=(0.16, 0.58) and a large move on day 2, what is β1(C)=0.9⋅0.1⋅0.16+0.1⋅0.7⋅0.58\beta_1(C)=0.9\cdot0.1\cdot0.16+0.1\cdot0.7\cdot0.58β1​(C)=0.9⋅0.1⋅0.16+0.1⋅0.7⋅0.58? Give three decimals.

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

On day one, α1β1=(0.0297, 0.0394)\alpha_1\beta_1=(0.0297,\ 0.0394)α1​β1​=(0.0297, 0.0394). What is the smoothed probability of Stormy, 0.0394/(0.0297+0.0394)0.0394/(0.0297+0.0394)0.0394/(0.0297+0.0394)? Give three decimals.

g=g =g=accepted: ± 0.003
4Numeric answer10 ptsNot answered

The sum α1β1\alpha_1\beta_1α1​β1​ over the two states must equal the probability of the data. What is 0.0297+0.03940.0297+0.03940.0297+0.0394? Give four decimals.

s=s =s=accepted: ± 0.0003
5Numeric answer10 ptsNot answered

On day one the filtered chance of Calm is 0.8180.8180.818 and the smoothed chance is 0.4300.4300.430. By how much did hindsight lower the belief in Calm? Give three decimals.

d=d =d=accepted: ± 0.003
6Choice10 ptsNot answered

What does smoothing use that filtering does not?

7Match10 ptsNot answered

Match each term with its meaning.

Pick the partner of each item on the left.

αt(i)\alpha_t(i)αt​(i)
βt(i)\beta_t(i)βt​(i)
γt(i)\gamma_t(i)γt​(i)
βT=1\beta_T=1βT​=1
8Explain in words15 ptsNot answered

In one or two sentences, explain why the smoothed probability of Calm on day one is lower than the filtered one in the example.

Math modeKeyboard or LaTeX inputTask 1 of 8 · 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