# 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 xx of a species of butterflies in any given population of butterflies follows a normal distribution with parameters μpop\mu_{pop} and Ïƒ. However, there are many different butterflies populations and each population has a different mean (μpop\mu_{pop}) of lengths (xx). The PDF of μpop\mu_{pop} follows an exponential distribution with parameter Î».

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

My Try

Below μpop\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ÂµxfÂµ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 xx 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

=================

1

=================

You need ParameterMixtureDistribution:

pmd = ParameterMixtureDistribution[NormalDistribution[Âµ, Ïƒ],
Âµ \[Distributed] ExponentialDistribution[Î»]]

CDF[pmd, x]

Exactly what I was looking for! Thanks a lot. +1
– Remi.b
Oct 22 ’14 at 18:16

@Remi.b, my pleasure. Thank you for the Accept.
– kglr
Oct 22 ’14 at 18:24