I am working this question:
Let $X$ and $Y$ be $[0,1]-$valued random variables such that $E[X^{n}]=E[Y^{n}]$ for every integer $n\geq 0$. Show that $E[f(X)]=E[f(Y)]$ for every continuous function $f:[0,1]\longrightarrow\mathbb{R}$ and conclude that $X=_{d}Y$. (Hint: use the Weierstrass approximation theorem)
Similar questions have been posted here:Show two random variables have same distribution
However, it seems that this question is asking me firstly to prove $E[f(X)]=E[f(Y)]$ for every continuous function, and then use this fact to deduce they have the same distribution.
The Weierstrass approximation theorem is here:
If $f$ is a real-valued function on $[a,b]$ and if any $\epsilon>0$ is given, then there exists a polynomial $P$ on $[a,b]$ such that $|f(x)-P(x)|<\epsilon$ for all $x\in [a,b]$.
So firstly I show that $n^{th}$ moment of random variable is always a polynomial? Even if I showed this, it seems that the argument is backward.
Answer with some more details will be really appreciated since I got really lost...
Thank you!
Edit 1:
As what the comment suggested, I should show $E[p(X)]=E[p(Y)]$ for all polynomial. However, I am reading Durrett, and there is nothing related to the relation between $n^{th}$ moment of a random variable and the expectation of a polynomial. I don't really know what to do here.
Also, as I pointed out in the comment of the first answer, if I know they have the same $n^{th}$ moment for each $n$, then using series expansion to the moment generating function immediately yields me that they have the same moment generating function and thus they have the same distribution. So why would I need to deduce this fact from $E[f(X)]=E[f(Y)]$?