# Arup Guha
# 4/13/2020
# Example showing use of numpy - matrix multiplication

# This example was shown in class. The hard-coded matrix is an example
# of a Markov Chain - a diagram that has probabilities of moving between
# some set of states. Exponentiating the matrix associated with a Markov
# chain to a high power uncovers steady state probabilities.

import numpy

# This is the example I made up in class.
# Weather condition 0 = sunny
# Weather condition 1 = cloudy
# Weather condition 2 = rainy
# Weather condition 3 = rainy
weather = numpy.array([[.4,.3,.2,.1],[.3,.5,.2,0],[.3,0,.7,0],[.3,.3,0,.4]])

# Will store my answer here.
weatherexp = weather

# This calculates the original matrix to the power 101 via repeated matrix
# multiplication (which is the @ sign).
for i in range(100):
    weatherexp = weatherexp @ weather

# To print a nice chart.
conditions = ["Sunny","Cloudy","Rainy", "Cold"]

# Chart header.
print("List of probabilities of going from one condition to another in 101 days.")

# Print out each entry.
for i in range(len(conditions)):
    for j in range(len(conditions)):
        print(conditions[i],"to",conditions[j],weatherexp[i][j])
