# Simple Hidden Markov Model

• ### Question

• Hi,

I've been trying to implement a very simple hidden markov model to understand the general concepts of how they are implemented in infer.net with c#.

I looked at the examples in Model and Model1 as well as the f# Version but I still don't get it.

Can anyone provide a very minimalistic example, for example for a hidden markov model consisting only of 3 timesteps for one site with 3 different states?

A simple Markov-1 Model with only the direct predecessor influencing the next state of a site would be perfect, I added an example for the graphical model as a picture.

Just something really easy to allow me to get the general concept behind the design.

Monday, June 18, 2012 9:39 AM

• Did you check out the WetGrassSprinklerRain example?  It demonstrates how to connect discrete variables with multiple states, and how to learn the CPTs.  To make a long chain, you can repeatedly invoke AddChildFromOneParent, passing in the same CPT each time.
• Marked as answer by Thursday, June 21, 2012 9:05 AM
Wednesday, June 20, 2012 4:42 PM

### All replies

• Even a simple example that is not a HMM would be very much appreciated, maybe that would already help me to get the basics:

Lets assume I have one discrete variable with 3 states (A,B,C)

The state is influenced by the variables state in the last timestep, there is a certain probability for a statechange to either B or C, if the node is currently in state A.

I have data for a number of state changes and want to find out the probabilities for all possible state changes.

How would I do this?

Tuesday, June 19, 2012 12:42 PM
• Did you check out the WetGrassSprinklerRain example?  It demonstrates how to connect discrete variables with multiple states, and how to learn the CPTs.  To make a long chain, you can repeatedly invoke AddChildFromOneParent, passing in the same CPT each time.
• Marked as answer by Thursday, June 21, 2012 9:05 AM
Wednesday, June 20, 2012 4:42 PM
• This is pretty much exactly what I was looking for.

I saw the example at some point, but didn't realize that the sourcecode was available as a solution.

Thanks!

Thursday, June 21, 2012 9:06 AM