Finding a transform of X Question: Y~ Uniform (0,1) and given Y=y, random variable X is binomial with parameters n and y. Find the transform (moment generating function) of X. Does X have a special name?
Attempt: I was trying to find the conditional transform first, i.e. M(x|y) (s) = E(e^sx | Y) = (1-y+ye^s)^n  (as X|Y is a binomial RV)
And I was thinking about the law of Iterated Expectation:
E[X] = E[E(X|Y)], but I am not sure how to go further from here.
Am I on the right track? Any ideas on how to do this problem?
Thanks a lot! 
 A: The conditional MGF of $X$ given $Y$ is $\mathbb E[e^{sX}|Y] = (Y (e^s-1) + 1)^n$, so the unconditional MGF is
$$\eqalign{\mathbb E[e^{sX}] &= \mathbb E \left[ (Y (e^s-1)+1)^n\right]\cr &= 
\int_0^1 (y (e^s-1)+1)^n\; dy\cr
&= \dfrac{e^{(n+1)s} - 1}{(n+1)(e^s-1)}}$$
Since $e^{(n+1)s} - 1 = (e^s - 1)(e^{ns} + e^{(n-1)s} + \ldots + 1)$, this does match the MGF of the discrete uniform distribution on $0, \ldots, n$.
A: Extended comment: As is @nullUser, I am unsure what you're trying to do for
a solution. Especially if this is from a course,
it would be easier to give an answer at the
appropriate level if you had said something about the
course and what you have studied recently. Were you
specifically asked to use an MGF? What common distributions
do you know about in addition to uniform and binomial?
A simple simulation in R based on a million
such experiments with $n = 5$ indicates that $Y$ has
a discrete uniform distribution on the integers 0 through 5.
That is, $$P(Y=0) = 1/6,\;P(Y=1) = 1/6,\dots,P(Y=5) = 1/6.$$
Similarly for other values of $n$.
It is possible to write simpler code, but maybe you can
more easily understand the following:
 m = 10^6;  n = 5;  x = numeric(m)
 for(i in 1:m) {
    y = runif(1);  x[i] = rbinom(1, n, y)  }
 table(x)/m
 ## x
 ##        0        1        2        3        4        5 
 ## 0.166418 0.166647 0.166987 0.166827 0.166885 0.166236 

Now that you know the answer, you might start by thinking about how it arises.  
