Weather probability with Markov chain

Today is windy. What is the probability that three days from now it will be raining if we have the weather transition matrix?

import numpy as np indices = ['rainy', 'sunny', 'cloudy', 'windy'] indices_len = len(indices) weather_probabilities = np.array([ [0.3, 0.3, 0.3, 0.1], [0.25, 0.2, 0.35, 0.2], [0.2, 0.3, 0.2, 0.3], [0.35, 0.2, 0.3, 0.15], ]) assert np.allclose(np.sum(weather_probabilities, axis=1), np.ones(indices_len)) == True today, future = 'rainy', 'sunny' today_idx = indices.index(today) future_idx = indices.index(future) days_from_now = 3 today_vec = future_vec = np.zeros(indices_len) today_vec[today_idx] = 1 print(np.dot(today_vec, weather_probabilities**days_from_now)[future_idx]) # 0.027 or 2.7%

Note: This is an approximate model that gets progressively inaccurate over time.