I was reading this book related to machine learning. It's given that for Mth order markov chain, the number of parameters = $K^{M-1}(K-1)$ where M is the order. I am not sure how this is derived.
For eg, lets say I have three states {Sunny, Cloudy, Rainy}. So at each time stamp I will look at the previous two states. So if I use the above formula, I will have 3*(2-1)*(3-1) = 6 which is less I guess. I should have the following parameters
P(Sunny|Cloudy,Rainy)
P(Sunny|Cloudy,Sunny)
P(Sunny|Cloudy,Cloudy)
P(Sunny|Rainy,Rainy)
P(Sunny|Rainy,Sunny)
P(Sunny|Rainy,Cloudy)
P(Sunny|Sunny,Rainy)
P(Sunny|Sunny,Sunny)
P(Sunny|Sunny,Cloudy)
and so on. It has lots of parameters isn't it higher than 6. I am bit confused. IT should be $K^{M}(K-1)$ I guess