State inference in HMM