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.




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[
   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}]

enter image description here

Hope this helps.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.