σμ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 1 · Chains and hidden states›Topic 1.1·~40 minIntermediate

Markov chains refresher

Skill positionModule 1 of 3 · Topic 1 of 2
1.1 Markov chains refresher
—Lab score— / 100Total XP—Streak—

Calm days and stormy days

A Markov chain is a system that hops between states, where the next state depends only on the current one, not on the whole past. Think of a market that is either Calm (C) or Stormy (S) each day. The rules fit in a transition matrix AAA: the entry AijA_{ij}Aij​ is the probability of going from state iii today to state jjj tomorrow. Each row adds up to 111. Say a calm day is followed by a calm day with probability 0.90.90.9 and by a stormy day with probability 0.10.10.1, and a stormy day is followed by a calm day with probability 0.20.20.2 and by another stormy day with probability 0.80.80.8.

A=(0.90.10.20.8),A2,πA=π,di=11−AiiA=\begin{pmatrix}0.9&0.1\\0.2&0.8\end{pmatrix},\qquad A^{2},\qquad \pi A=\pi,\qquad d_i=\frac{1}{1-A_{ii}}A=(0.90.2​0.10.8​),A2,πA=π,di​=1−Aii​1​(1)

To look two days ahead, multiply the matrix by itself: A2A^{2}A2 holds the two-step probabilities. Run the chain for a long time and the share of days in each state settles at the stationary distribution π\piπ, which satisfies πA=π\pi A=\piπA=π: one more step does not change it. A state with self-probability AiiA_{ii}Aii​ is kept for 1/(1−Aii)1/(1-A_{ii})1/(1−Aii​) days on average, so persistent states produce long streaks. These are the same ideas that later let us describe market regimes: calm periods and stormy periods that last for a while.

Numbers for our marketFrom calm today, the chance of a stormy day in two days is 0.9×0.1+0.1×0.8=0.170.9\times0.1+0.1\times0.8=0.170.9×0.1+0.1×0.8=0.17. In the long run the share of calm days solves πC=0.9πC+0.2πS\pi_C=0.9\pi_C+0.2\pi_SπC​=0.9πC​+0.2πS​, which gives πC=0.2/(0.1+0.2)=0.667\pi_C=0.2/(0.1+0.2)=0.667πC​=0.2/(0.1+0.2)=0.667, so two days in three are calm. A calm stretch lasts 1/(1−0.9)=101/(1-0.9)=101/(1−0.9)=10 days on average and a stormy one 1/(1−0.8)=51/(1-0.8)=51/(1−0.8)=5 days.
  • Markov property: tomorrow depends only on today's state, not on how we got here.
  • Stationary distribution π\piπ: the long-run share of days in each state, with πA=π\pi A=\piπA=π.
  • Duration: a state with self-probability ppp lasts 1/(1−p)1/(1-p)1/(1−p) days on average.

Lab · what's graded

  • Two days ahead15 pts
  • The long-run share of calm days15 pts
  • A calm stretch10 pts
  • A stormy stretch10 pts
  • A short path10 pts
  • The Markov property10 pts
  • Match the vocabulary15 pts
  • Why stormy days come in streaks15 pts
0/ 8 answered
Tasks
1Numeric answer15 ptsNot answered

Today is calm. What is the probability that the day after tomorrow is stormy, ACCACS+ACSASSA_{CC}A_{CS}+A_{CS}A_{SS}ACC​ACS​+ACS​ASS​? Give two decimals.

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

What is the stationary probability of a calm day, πC=ASC/(ACS+ASC)\pi_C=A_{SC}/(A_{CS}+A_{SC})πC​=ASC​/(ACS​+ASC​)? Give three decimals.

p=p =p=accepted: ± 0.003
3Numeric answer10 ptsNot answered

How many days does a calm stretch last on average, 1/(1−ACC)1/(1-A_{CC})1/(1−ACC​)?

d=d =d=accepted: ± 0.05
4Numeric answer10 ptsNot answered

How many days does a stormy stretch last on average, 1/(1−ASS)1/(1-A_{SS})1/(1−ASS​)?

d=d =d=accepted: ± 0.05
5Numeric answer10 ptsNot answered

Starting calm, what is the probability that the next two days are calm and then stormy, ACCACSA_{CC}A_{CS}ACC​ACS​?

p=p =p=accepted: ± 0.002
6Choice10 ptsNot answered

What does the Markov property say?

7Match15 ptsNot answered

Match each term with its meaning.

Pick the partner of each item on the left.

Transition matrix
A2A^{2}A2
Stationary distribution
Expected duration
8Explain in words15 ptsNot answered

In one or two sentences, explain why a high self-probability such as ASS=0.8A_{SS}=0.8ASS​=0.8 makes stormy days come in streaks.

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