# operate with the categorical distribution (expectations etc)

I have a question regarding the categorical distribution. I have been deriving all the equations involved in the Gaussian Mixture model and I have realized that I don really understand the representation of the Categorical distribution.

As far as I understand the typical representation of the categorical distribution is using a one hot representation. So if we have a $$K$$ categorical distribution (let's use K=3 to exemplify) then $$z_2=1$$ means that $$z=(0,1,0)$$. The probability distribution is written down as $$p(z)=\overset{K}{\prod} {\pi_k}^{z_k}$$ with $$\underset{k}{\sum}\pi_k = 1$$. Does this means that when computing expectations and so on I should use a scalar whenever I encounter $$z_k$$ and a vector representation whenever I encounter $$z$$?

I am interested, for example, in these three computations.:

$$\mathbb{E}[z] = \underset{z}{\sum}z \overset{K}{\prod} {\pi_k}^{z_k} = (1,0,0)\pi_1 + (0,1,0)\pi_2 + (0,0,1)\pi_3 = (\pi_1,\pi_2,\pi_3)$$

$$\underset{z}{\sum} p(z) = \underset{z}{\sum}\overset{K}{\prod} {\pi_k}^{z_k} = \pi_1+\pi_2+\pi_3 = 1$$

$$\underset{z}{\sum} z_1 p(z) = \underset{z}{\sum} z_1\overset{K}{\prod} {\pi_k}^{z_k} = ?$$

For the last computation I know that the solution is $$\pi_1$$ but I am not able to derive it using the representation exposed above. So I think I am not interpreting correctly the way in which the categorical distribution should be represented and thus how to operate with it. This last computation appears in slide 38 here http://www.cs.toronto.edu/~rsalakhu/sta4273_2013/notes/Lecture5_2013.pdf