type: Concept title: "Hidden Markov Model (HMM)" description: "A model where the market sits in one of a few unobserved states, each with its own return distribution, switching with fixed probabilities." tags: [hidden markov model, regime detection, statistics] status: stable generated: { by: grok-bot/alpha-explainer-2.0, at: "2026-10-16T02:45:00Z" } kb_id: th-concept-hidden-markov-model topics: [market regimes] alpha: strategy_families: [regime switching] complexity: intermediate relations: explainers: [/explainers/hmm-rl-regime-allocation.md] repos: [/repos/gh-hmmlearn-hmmlearn.md]

Definition

An HMM assumes a hidden state (for example calm, transitional, crisis) that you never observe directly. Each state emits observations (returns) from its own distribution, and the state changes according to a transition matrix.

Filtering vs smoothing (important for backtests)

Seen in

---
type: Concept
title: "Hidden Markov Model (HMM)"
description: "A model where the market sits in one of a few unobserved states, each with its own return distribution, switching with fixed probabilities."
tags: [hidden markov model, regime detection, statistics]
status: stable
generated: { by: grok-bot/alpha-explainer-2.0, at: "2026-10-16T02:45:00Z" }
kb_id: th-concept-hidden-markov-model
topics: [market regimes]
alpha:
  strategy_families: [regime switching]
  complexity: intermediate
relations:
  explainers: [/explainers/hmm-rl-regime-allocation.md]
  repos: [/repos/gh-hmmlearn-hmmlearn.md]
---

# Definition

An HMM assumes a hidden state (for example calm, transitional, crisis) that you never observe directly. Each state emits observations (returns) from its own distribution, and the state changes according to a transition matrix.

# Filtering vs smoothing (important for backtests)

- **Filtered** probability: uses data up to bar *t* only. Safe for live trading and honest backtests.
- **Smoothed** probability and the **Viterbi** path: use the whole sequence, including bars after *t*. Great for labelling history, but they leak the future if you trade on them.

# Seen in

- [HMM + RL regime allocation explainer](/explainers/hmm-rl-regime-allocation.md)
- [hmmlearn](/repos/gh-hmmlearn-hmmlearn.md), a Python HMM library ([deep-dive](/deep-dives/gh-hmmlearn-hmmlearn.md))