# Using Markov chains for basketball

The NBA hackathon application process asked a fun question that I got excited about:

Given that the Warriors win a game with probability 0.800,
what’s the probability that they play an entire 82-game
season without consecutive losses?


I modeled the season as a Markov chain. There are 3 states: W, L, and 2L. W transitions to itself with $p = 0.8$ and L with $p = 0.2$. L transitions to W with $p = 0.8$ and 2L with $p = 0.2$. 2L transitions to itself with $p = 1$. This results in the following transition matrix: $% $ where the columns represent the “source” states and the rows are the “destination” states. We start off with $p = 0.8$ of being in state W, $p = 0.2$ of being in state L, and $p = 0$ of being in state 2L, so $s_1 = [0.8, 0.2, 0]^\top$ and we need to solve for $s_82$.

% .

Therefore, the probability of the Warriors never losing consecutive games is $1 - 0.94119314 = 0.05880686$.

If you loosen the $p = 0.8$ assumption and tried to model their season as a function of their opponents, their rest schedule, etc. that would be much more difficult. You would need to use some more involved ML techniques.