0
$\begingroup$

I'm using the following transformed random variables

hX = TransformedDistribution[(z + 1/3)^2, 
  z \[Distributed] NormalDistribution[0, 1]]
hY = TransformedDistribution[(z + 1/3)^2, 
  z \[Distributed] NormalDistribution[1, 2]]

First I tried to plot the PDF of hY by running

Plot[PDF[hY, x], {x,0,1}]

But the plotting fails as some branches of the PDF are not well-defined (even though in the interval (0,1) everything is of course okey). I found a work around on this with Refine[..., x>0] but I would like to know what causes Mathematica to not be able to plot it without it? Any other ways to do it?

Next I wanted to plot the composition function

1 - Refine[CDF[hY, InverseCDF[hX, 1 - x]], InverseCDF[hX, 1 - x] > 0]

But when I run the code

Plot[1 - Refine[CDF[hY, InverseCDF[hX, 1 - x]], 
   InverseCDF[hX, 1 - x] > 0], {x, 0, 1}, ImageSize -> 600]

It is quite slow (something between 30-60 seconds). Any way to make this faster? I know that it is not that slow but if the distributions were even more complex I bet it would slow down even more. Any way to make it faster? Maybe there are some commands that I don't know of make it faster? Or maybe there is some much faster approximate method.

$\endgroup$
  • $\begingroup$ tried Plot[Evaluate@PDF[hY, x], {x, 0, 1}]? $\endgroup$ – kglr Apr 10 at 8:39
  • $\begingroup$ @kglr Great. That solves the first problem but not the second. $\endgroup$ – Harto Saarinen Apr 10 at 13:27

Your Answer

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

Browse other questions tagged or ask your own question.