How can I prove $E[g(X)] = \sum g(x)f (x)$? Let $X$ be a random variable and $g(x)$ be any function of $X$.
If $X$ is continuous, then the expectation of $g(X)$ , we have
$E[g(X)] = \int g(x) f(x) \, dx$,
where $f(x)$ is the probability density function of $X$. For example, take the case of a sinusoid with uniformly distributed phase variable. But with that knowledge how can I say the random sinusoid also follows the uniform distribution, which is the case?
How can I prove this? I don't find this straight forward.
But I can see the logic in $E[X] = \int x f(x) \, dx$.
At least any references or links would be helpful.

The statement where you have problems with understanding is called the law of the unconscious statistician. You can read a bit more (maybe this will help you) here.
Also as  Michael Hardy has noticed uniformly distributed phase is not a discrete random variable (usually). So you should use a continuous analog for expectation. And also the fact you assume that their expected values are the same does not tell you anything about the agreement of their pdf's.
