Implementation of a basic HMM in Java