I was reading a book of probability and in the demonstration of: $ E(h(X)) = \sum_{x\in R_x}h(X) \cdot p_X(x) $. The next step confused me, because I don't get what means the thing under the last summation:
$ E( Y = h(X) ) = \sum_{j}y_j \cdot p_Y(y_j) = \sum_{j}y_j \cdot \sum_{i|h(x_i) = y_j} p_X (x_i) $.
This means that you will sum over all $x_i|h(x_i) = y_j$ ?