Data Science, Towards Data Science, Markov Chains, Monte Carlo, Simulation.
word_dict.keys(): word_dict[word_1].append(word_2) else: word_dict[word_1] = [word_2] Finally we pick some random word to kick off the chain, and choose the number of words we want to simulate: first_word = np.random.choice(corpus) chain = [first_word] n_words = 30 After the first word, every word