# Discrete random variable decomposition over sample space

If $X$ is a discrete random variable taking values in $\{1,\dots,N\}$, does the sample space decomposition identity $X=\sum_{k=1}^N k1_{\{X=k\}}$ always hold, or are there instances where it might not be true? This might be a somewhat naive question, but I am trying to understand if we can always write that identity without "further justification"? Any comments or references to literature would be greatly appreciated.

• Can you write this for an integer $1\le x\le N$? – d.k.o. May 8 '16 at 0:45
• @d.k.o. yes, but when we have a random variable I am wondering if there is any need to justify the identity? – user223935 May 8 '16 at 0:56

It is true. More generally, if $X$ takes values in a countable (i.e., finite or countably infinite) set $S$, then $$X = \sum_{x \in S} x \mathbf{1}_{\{X = x\}}.$$ This identity is easy to justify: both sides are equal for every $\omega$ in the domain of $X$.