Estimate the HMM parameters (2states), backward I fitted a 2-states-HMM model last week, and generate a bunch of 1s and 0s, but I forgot to store its parameters (transition matrix). Now, I only got these 1s and 0s, how do I backward/reverse-engineering to estimates these transition matrix?
Things that I have:

*

*the input data

*the outputed 0s and 1s from a fitted 2-states-HMM

What I want:

*

*The transition matrix of the HMM model.

 A: What you call "backward/reverse-engineering to estimate the transition matrix" is actually a common problem called system identification. Given a set of inputs and observations, how can I estimate the parameters (i.e. the transition and emission matrices, as well as the noise covariance matrices if applicable) of the state space system which generated these observations?
To the best of my knowledge (see my other answer here), there are two different ways to perform system identification with HMM:

*

*The Expectation-Maximization algorithm (EM), which is an iterative method to find (local) maximum likelihood or maximum a posteriori (MAP) estimates of parameters in statistical models, where the model depends on unobserved latent variables (cf here). Here, the latent variables correspond to the hidden states of your HMM, which is unobserved since you only have access to the outputs of the system (i.e. the 0s and 1s).

*The subspace method, in which observations are stacked as a Hankel matrix and decomposed using singular value decomposition to read out the matrices of the system.

Both methods are explained in the BRML textbook (Chapter 24.5.3) accessible online. The exact implementation of the solution is going to depend on whether your system assumes a continuous or discrete latent state (which you did not specify, but the BRML textbook covers both cases), and on whether your observations are a deterministic or stochastic function of the latent state.
Moreover, different off-the-shelf tools exist in different programming languages to study HMM. The first that is coming to my mind is the HMMBase package for Julia (see the documentation here), which fit_mle function implements the EM algorithm to infer the matrix of the system from its observations.
