# Plot a product of Beta distributions

I would like to plot the PDF of the product of a $Beta(1,1)$ and $Beta(3/2,1/2)$ random variables. I can use the following to calculate the PDF at a point $x$:

PDF[TransformedDistribution[u v, {u \[Distributed] BetaDistribution[1, 1],
v \[Distributed] BetaDistribution[3/2, 1/2]}], x]


However, to work out the PDF at a point (take $x=0.5$ for example), the above takes about 10 minutes on my computer.

I could leave my computer overnight, and it should be able to plot the above PDF using $Plot$, however, I was wondering whether there are any quicker alternatives?

Note: I want to plot the distribution's PDF exactly, not an approximation by drawing randomly first a $Beta(1,1)$ then multiplying it by a draw from $Beta(3/2,1/2)$, then looking at a histogram.

Best,

Ben

## 1 Answer

From what I can tell you are recalculating the transformed distribution too often in your plot. Calculate and store the resulting PDF once and then use it for your plots.

tpdf = PDF[
TransformedDistribution[
u v, {u \[Distributed] BetaDistribution[1, 1],
v \[Distributed] BetaDistribution[3/2, 1/2]}], x]


Once you have tpdf your plot will return immediately since you are not recalculating it for each value of x.

Plot[tpdf, {x, 0, 1}]


Hope this helps.

• …and if OP would rather skip the use of an auxiliary variable, there's the option setting Evaluated -> True. – J. M.'s ennui Aug 11 '15 at 16:41
• @Guesswhoitis. Is this an option on Plot? I can't seem to find it in 10.2 – Edmund Aug 11 '15 at 17:21
• @Edmund - use Plot[Evaluate[PDF[..., x]], {x, 0, 1}] – Bob Hanlon Aug 11 '15 at 18:49
• Yes, it's an option for Plot[]. – J. M.'s ennui Aug 12 '15 at 0:27