# What is the PDF of a variable where a parameter is itself a random variable?

Question

How do we analyze in Mathematica cases where a parameter in a Probability Density Function (PDF) varies according to another PDF? Consider the following example...

Example

The text below contains absolutely no biological reality. I just made it up!

The size $x$ of a species of butterflies in any given population of butterflies follows a normal distribution with parameters $\mu_{pop}$ and σ. However, there are many different butterflies populations and each population has a different mean ($\mu_{pop}$) of lengths ($x$). The PDF of $\mu_{pop}$ follows an exponential distribution with parameter λ.

What is the overall PDF of $x$ (butterflies size) in all populations given the PDF of $x$ in any given population and the PDF of $\mu_{pop}$?

My Try

Below $\mu_{pop}$ is renamed µ for ease of reading.

fx[µ_, σ_] = NormalDistribution[µ, σ];

fµ[λ_] = ExponentialDistribution[λ];

fµx[µ_, σ_, λ_] =
ProductDistribution[fx[µ, σ], fµ[λ]];

PDF[fµx[µ, σ, λ], {x, µ}]


...but it is definitely not the right way of modeling this problem because what $fµx$ is some weird joint distribution while what I am looking for is not a joint distribution but I am looking for the overall PDF of $x$ given that the parameter $\mu$ is exponentially distributed among populations with parameter λ.

• Why are you wrapping PDF around fµx? Why isn't fµx good enough? The only suggestion I have is to maybe write fµx[ƛ_][µ_, σ_]. I think you need to explain what you're doing and why/how you're going to use this fµx function. Also, ƛ is a bit of an odd character to use. Why not just λ? – Kellen Myers Oct 22 '14 at 17:27
• Thanks for your comment. I was indeed scared my question was unclear. I updated it to add some explanation at the very end that may clarify my point. Let me know if it does? Note, it is likely that some lack of knowledge in probability theory leads me to poorly phrased my question! I used ƛ instead of λ because I couldn't find λ on my Mac french-language swiss keyboard! I now copy-pasted your λ character and edited my question. Thanks – Remi.b Oct 22 '14 at 17:46

pmd = ParameterMixtureDistribution[NormalDistribution[µ, σ], 