# Is this TransformedDistribution beyond Mathematica?

Creating the following transformed distribution $$A$$

A = TransformedDistribution[Sqrt[x^2], x \[Distributed] NormalDistribution[\[Mu], \[Sigma]]]


and then using A to create another TransformedDistribution $$B$$,

B = TransformedDistribution[1/2 + Sqrt[c^2 d^2 (d^2 - c x^2)]/(2 c d^2), x \[Distributed] A]


seems to get Mathematica stuck on

PDF[B, x]


Or is it me doing something wrong?

• In general, finding the PDF is likely to involve integration. If Mathematica struggles with the integral, it will struggle with the PDF. It may return useful results for numerical values of x Oct 7 '18 at 13:03
• Could I generate many values for $A$, and produce the corresponding values for $B$ using Mathematica? If so, how? Oct 7 '18 at 13:27

In the general case the random variable B is complex-valued. It should also be noticed that B depends on four parameters. All that is too hard even for the human mind. Mathematica answers the question for concrete values of c and d, eg

A = TransformedDistribution[RealAbs[x],x \[Distributed] NormalDistribution[\[Mu],[Sigma]]]
B = TransformedDistribution[1/2 + Re[Sqrt[ (1 - x^2)]/(2 )],x \[Distributed] A];
PDF[B,x]//TeXForm


$$\begin{array}{cc} \{ & \begin{array}{cc} \frac{(2 x-1) e^{-\frac{\mu ^2-4 x^2+4 x}{\sigma ^2}} \left(e^{\frac{\left(\mu -2 \sqrt{-(x-1) x}\right)^2}{2 \sigma ^2}}+e^{\frac{\left(\mu +2 \sqrt{-(x-1) x}\right)^2}{2 \sigma ^2}}\right)}{\sqrt{2 \pi } \sigma \sqrt{-(x-1) x}} & \frac{1}{2}1\lor x<\frac{1}{2} \\ \text{Indeterminate} & \text{True} \\ \end{array} \\ \end{array}$$

The result of

PDF[TransformedDistribution[Im[Sqrt[ (1 - x^2)]/(2 )],x \[Distributed] A], x]


is similar.

If you restrict the values of $$c$$ and $$d$$ to real values where $$c<0$$ and $$d\neq 0$$, then all values of the desired random variable are real and a symbolic solution exists. (With more work maybe other symbolic solutions exist if the conditions on $$c$$ and $$d$$ are relaxed - I won't tackle that.)

We see that with $$c<0$$ and $$d\neq 0$$

FullSimplify[1/2 + Sqrt[c^2 d^2 (d^2 - c x^2)]/(2 c d^2), Assumptions -> {c < 0, d != 0}]


$$\frac{1}{2}-\frac{\sqrt{d^4-c d^2 x^2}}{2 d^2}$$

Because of the restrictions we can simplify this to

$$\frac{1}{2}-\frac{1}{2} \sqrt{1-\frac{c x^2}{d^2}}$$

Because we know that $$-c/d^2$$ is positive, we can further simplify to

1/2 - Sqrt[1 + e x^2]/2


Now a symbolic solution can be obtained:

a = TransformedDistribution[Sqrt[x^2], x \[Distributed] NormalDistribution[μ, σ]];

b = TransformedDistribution[1/2 - Sqrt[1 + e x^2]/2, x \[Distributed] a,
Assumptions -> {e > 0}];
PDF[b, z]


$$\begin{array}{cc} \{ & \begin{array}{cc} \frac{\frac{(1-2 z) e^{-\frac{\left(2 \sqrt{e} \sqrt{(z-1) z}+e\right)^2}{8 e^2}}}{\sqrt{e} \sqrt{(z-1) z}}+\frac{(1-2 z) e^{-\frac{1}{8} \left(1-\frac{2 \sqrt{(z-1) z}}{\sqrt{e}}\right)^2}}{\sqrt{e} \sqrt{(z-1) z}}}{2 \sqrt{2 \pi }} & z\leq 0 \\ 0 & \text{True} \\ \end{array} \\ \end{array}$$