When a random variable has a distribution whose parameter is another random variable Is there a standard name for a situation where a random variable follows a distribution whose parameter is another random variable ? For example a binomial(15,p) variable where the the p is distributed as beta(1,2), or a Poisson(Y) where Y is distributed as exponential(2)
Is this called a compound distribution, or ?
Then my real question is, given Y is distributed according to some given pdf with parameter X (say pdf1), but X is distributed according to another distribution (say pdf2), how do I use Bayes rule:
$$
f_{X|Y}(x|y)=\frac{f_{Y|X}(y|x) \, f_X(x)}{f_Y(y)}
$$
?
$f_X(x)$ must just be pdf2, right ?
Is $f_{Y|X}(y|x)$ just the pdf of Y (that is, pdf1) with the pdf of X substituted in place of X ? 
How do I work out $f_Y(y)$ ?
I hope it isn't asking too much for someone to tell me the general approach and also give an example of this, not necessarily one of those I mentioned above.
I have looked in several statistics books but I didn't find the answer. 
 A: There is nothing Bayesian (in the sense of "inverse" probability
calculations) in this problem, only the law of total probability.
Of course, the law of total probability requires assumptions about
a priori probabilities.... 
Using the illustrations in the question, suppose that there are random variables
$Y$ and $X$ where $Y$ has a binomial distribution $\text{Binom}(15,X)$.
(Note that $X$ must take on values in $[0,1]$ only)
What this is saying is that conditioned on the value of $X$, $Y$ is a binomial
random variable.  Thus, the conditional distribution of $Y$ given the
value of $X$ is a binomial distribution $\text{Binom}(15,X)$.  Perhaps
this is the name that you are looking for when you ask "Is this called a compound distribution, or ..."?
The unconditional distribution of $Y$ is, in general,
not a binomial distribution.  It is, in fact, a mixture distribution.
This is particularly visible in the case when $X$ is a discrete random
variable because then the unconditional distribution of $Y$ is a
weighted sum of the conditional distributions.
For our particular example, we have that for $0 \leq n \leq 15$,
$$P\{Y = n\} 
= \begin{cases}\sum_i \binom{15}{n}\alpha_i^n (1-\alpha_i)^{15-n}\cdot P\{X = \alpha_i\}, & X ~\text{a discrete random variable,}\\
\int_0^1 \binom{15}{n}\alpha^n (1-\alpha)^{15-n}\cdot f_X(\alpha)\,\mathrm d\alpha, & X ~\text{a continuous random variable,}
\end{cases}$$
A: I'm a novice at this myself, but I have gotten a lot of mileage out of Data Analysis: A Bayesian Tutorial by Devinderjit Sivia and John Skilling.
What I think you have described, however is Bayesian parameter estimation for a parameter $p$, say perhaps the probability associated with a coin coming up heads. The function $f_{X|Y}$ is the distribution of that parameter.
If this is the case you would call $f_{Y|X}$ you likelihood function, which we could take as a binomial, since our evidence would be a series of coin flips. Note that the parameter of $f_{X|Y}$ is not so much "y" as it is the number of heads and tails thrown (i.e. $f_{X|Y}(x;\#heads, \#tails)$ as this is what you need to properly parameterize your binomial.
As for $f_X$ it is our prior, which we could take to be uniform. $f_{X|Y}$ is our posterior, which ends up being a beta distribution for the case I just described.
As for $f_Y$ it doesn't really matter if you are just trying to find the best value for the parameter, because it's a normalization factor. However if you need the distribution then it's the integral over the range of the possible values of $x$, in this case $[0,1]$.
This article on Wikipedia may help as well. http://en.wikipedia.org/wiki/Checking_whether_a_coin_is_fair
A: The standard way to do this is usually through transforms.
One starts with the transform of the outer variable, for a given outcome of the inner, and then averages over the resulting expression. Then one needs to go back.
See for example page 77 in A. Gut "An intermediate course in probability".
This is a standard undergraduate problem.
