Suppose that I have a task of classifying a time series. I decide to use Hidden Markov Model $\lambda(A, B, \pi)$, where $A$ is a transition matrix, $B$ is an emission probability, $\pi$ is an initial distribution. An observed stochastic process looks as below

enter image description here

and there are two unobserved states: State 1 and State 2, also shown on the plot. Let's say, that I would like to fit HMM and test how it performs in terms of states recognition. The best thing I can probably do is to split my data into the train and test set but in a specific manner: the last $n$ observations make up my test set (the part to the right of the dotted green line), as I cannot use crossvalidation due to the temporal structure of the data. But there is a problem: to reliably assess the performance (measured as i.e. accuracy), I need at least a few transitions between the states that this data doesn't provide.

Question: is there any method that allows creating synthetic data for this kind of data? One thing I was considering was to reverse the whole training set, add some gaussian noise and tack on the end of the original training set.


1 Answer 1


If you know the parameters $(\pi, A, B)$ of the system you want to simulate, then it should be a pretty straightforward process.

Simply draw a uniform random number and compare it to the probabilities from the starting distribution $\pi$ to generate an initial state. Then draw a random number and generate an outcome according to the probabilities for the current state by comparing it to the outcome probabilities in $B$. Draw another random number, and transition to a new state (or don’t) according to the probabilities in $A$. Generate another random number and compare it to $B$ to generate an outcome for this second state. Draw a new random number to simulate a state transition… etc. Simply continue this process until you reach your desired sequence length.

I’m happy to elaborate on any of these steps in the comments if you have any questions. It’s possible that I am misunderstanding your question.

  • $\begingroup$ Thanks for the response. The initial goal is to assess the performance of my classifier. In order to do that, I simply need more transitions between the states and it therefore more data, so I cannot really generate it from my model. $\endgroup$
    – thesecond
    Sep 25, 2022 at 12:08
  • $\begingroup$ If you do the process that I described, you can then estimate the parameters from your new simulated dataset. If you need a lot of transitions, I would suggest simulating ~1000 sequences and doing the estimation on each one. Some will have more transitions and some will have less, and the parameters you estimate will vary on each simulation. But since you know the true parameters that generated them, you can use that knowledge to accuracy and precision of the estimator. This is called Markov-chain Monte Carlo $\endgroup$
    – phil
    Sep 26, 2022 at 16:56
  • $\begingroup$ You can also use it to ask questions about classification accuracy, by looking at the hidden states that you infer and comparing them to the true states (that you know because the data are simulated.) The question this answers is roughly: Assuming that my parameter estimates are correct, how good will this classifier perform on other data generated by this process? $\endgroup$
    – phil
    Sep 26, 2022 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.