Added analysis function, generating a markov chain