# Just what kind of transformations can TransformedDistribution handle?

Why does the following command return an empty plot?

Plot[PDF[TransformedDistribution[(2 Z - 1) X,
{Distributed[X, ExponentialDistribution[1]],
Distributed[Z, BernoulliDistribution[0.5]]}], t], {t, -1, 1}]


Yet RandomVariate works just fine:

SmoothHistogram@RandomVariate[TransformedDistribution[(2 Z - 1) Abs[X],
{Distributed[X, ExponentialDistribution[1]],
Distributed[Z, BernoulliDistribution[0.5]]}], 1.*^5]


I merely give a particular example; don't focus unduly on it, I want to generalize.

-
Have you checked that the function PDF[...] actually returns values ? – b.gatessucks Apr 26 '12 at 8:24
TransformedDistribution doesn't seem to like products of distributions, or the mixture of Exponential and Bernoulli, – image_doctor Apr 26 '12 at 10:16
This is a continuous distribution (the Laplace or Double Exponential), so that's not the problem. A little testing with simpler expressions suggests TransformedDistribution isn't anything more than a toy at this point: it can take a large amount of computation to obtain simple sums (such as adding an Exponential to a Gamma variate), if it succeeds at all, and simply fails quietly when evaluating most multivariate expressions. – whuber Apr 26 '12 at 14:52
My answer is no longer an answer to your question since your edits, so I have deleted it. – Verbeia Apr 26 '12 at 23:14

## 1 Answer

TransformedDistribution contains a collection of identities known to it, like that of sum of normals being equal in distribution to another normal random variable, and a general machinery to work out properties of the functions of random variables.

Most of the time the computation will be done by the general machinery, which relies on solvers, like Expectation and Probability. Hence TransformedDistribution will be as strong as those are.

The major strength of TransformedDistribution, in my opinion, is that it allows for easy and efficient sampling. It is generally expensive to work out other properties of the random variable from this representation.

In this particular example of $(2 Z-1) X \stackrel{d}{=} -(-1)^Z X$ the underlying solvers did not know how to handle the mixed case of discrete and continuous distribution:

In[11]:= di =
TransformedDistribution[(2 z - 1) x, {z \[Distributed]
BernoulliDistribution[1/2],
x \[Distributed] ExponentialDistribution[1]}];

In[12]:= CDF[di, z]

Out[12]= CDF[
TransformedDistribution[(-1 +
2 \[FormalX]1) \[FormalX]2, {\[FormalX]1 \[Distributed]
BernoulliDistribution[1/2], \[FormalX]2 \[Distributed]
ExponentialDistribution[1]}], z]


As it is often the case, one can work out the answer in an alternative way:

In[13]:= CharacteristicFunction[di, t] // Simplify

Out[13]= 1/(1 + t^2)

In[14]:= pdf =
InverseFourierTransform[%, t, x, FourierParameters -> {1, 1}]

Out[14]= 1/2 E^-Abs[x]

-