# Basic question about Hidden Markov Models

**URL:** https://discourse.julialang.org/t/basic-question-about-hidden-markov-models/46453
**Category:** Offtopic
**Tags:** hmm
**Created:** [September 11, 2020, 12:46pm UTC](https://discourse.julialang.org/t/basic-question-about-hidden-markov-models/46453 "2020-09-11T12:46:30Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [September 11, 2020, 12:46pm UTC](https://discourse.julialang.org/t/basic-question-about-hidden-markov-models/46453/1 "2020-09-11T12:46:30Z")

</div>

I don’t have any experience with Hidden Markov Models but I have a problem that I’m trying to solve that I believe fits within the HMM framework. I’ve been reading about HMMs ([this resource](https://web.stanford.edu/~jurafsky/slp3/A.pdf) is particularly nice) and I’ve been playing with some toy examples via HMMBase.jl.

The question I have is, in the _real_ world, how would I know the transition probabilities for a process I’m unable to observe? I can make educated guesses about the observation likelihoods/emission probabilities but in my case, I don’t really have any idea what the transition probabilities would be.

I’ve thought about using a particular data source as a proxy for the hidden process but, if I can do that in a way that’s satisfactory, it seems to me that I would just want to use that data source/model to solve my problem.

Can anyone provide some advice, point me to some resources that can assist, or discuss a similar problem where the transition probabilities had to be approximated somehow?

Thanks!!

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [September 11, 2020, 1:09pm UTC](https://discourse.julialang.org/t/basic-question-about-hidden-markov-models/46453/2 "2020-09-11T13:09:57Z")

</div>

Usually you estimate both the hidden transition probabilities and the observation distributions using data, similarly to any other model. If your methodology allows (eg Bayesian/MAP), you can incorporate the “educated guesses” as informative priors.

That said, HMMs can suffer from weak identification for a lot of practical examples (aside from the trivial index exchange one). The more you can constrain the process using _a priori_ knowledge, the better.

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [September 11, 2020, 1:22pm UTC](https://discourse.julialang.org/t/basic-question-about-hidden-markov-models/46453/3 "2020-09-11T13:22:34Z")

</div>

Thanks, Tamas. I was actually hoping you would see this and provide some insight 🙂

---

<div class="post-metadata">

### Author: ![mschauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mschauer/32/13946_2.png) [@mschauer](https://discourse.julialang.org/u/mschauer)
#### Post date: [September 11, 2020, 1:38pm UTC](https://discourse.julialang.org/t/basic-question-about-hidden-markov-models/46453/4 "2020-09-11T13:38:41Z")

</div>

Yeah, sometimes you can pin down the structure/entries of your transition probability matrix from physical reasoning/domain knowledge up to some unknown parameters, which you then can estimate jointly with the latent trajectory using Bayesian methods. This about the same as having a prior on the transition probability matrix, but it’s just more natural to think about transition densities with unknown parameters sometimes.

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [September 11, 2020, 2:09pm UTC](https://discourse.julialang.org/t/basic-question-about-hidden-markov-models/46453/5 "2020-09-11T14:09:50Z")

</div>

In case anyone else finds this, Turing has a nice tutorial on this:

[https://turing.ml/dev/tutorials/4-bayeshmm/](https://turing.ml/dev/tutorials/4-bayeshmm/)

---

<div class="post-metadata">

### Author: ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)
#### Post date: [September 12, 2020, 1:25pm UTC](https://discourse.julialang.org/t/basic-question-about-hidden-markov-models/46453/6 "2020-09-12T13:25:52Z")

</div>

You can also think of the transition probabilities as their corresponding stochastic process, for example if you have a Normal transition probably it means the hidden state is a Brownian motion, a process that can wander up and down, with a “flexibility” that depends on the variance of the normal.  
But you could also use a Ornstein–Uhlenbeck process, which tends to gravitate around a mean value.

---

<div class="post-metadata">

### Author: ![mschauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mschauer/32/13946_2.png) [@mschauer](https://discourse.julialang.org/u/mschauer)
#### Post date: [September 13, 2020, 10:56am UTC](https://discourse.julialang.org/t/basic-question-about-hidden-markov-models/46453/7 "2020-09-13T10:56:34Z")

</div>

I can relate to this a lot! Part of my work is just about paying attention the continuous time models like Brownian motion in the background to make inference for discrete time process like a Markov chain easier.
