Javascript implementation of Markov Chains