Is there a bug in the TransformedDistribution function?

In a simple example I tried to use TransformedDistribution to define a probability distribution of a variable that is +/- 1 with probability 1/2. Doing so results in an extraneous value in the resulting PDF.

z = TransformedDistribution[2 x - 1, x \[Distributed] BinomialDistribution[1, 1/2]]
PDF[z][Range[-2, 2]]
{0, 1/2, 2/\[Pi], 1/2, 0}

There does not seem to be a problem in defining the Binomial distribution for a single trial.

w = TransformedDistribution[x, x \[Distributed] BinomialDistribution[1, 1/2]];    
PDF[w][Range [-1, 2]]    
{0, 1/2, 1/2, 0}

I am running Mathematica Home Edition version 10.0.2

Just an update:

When I explicitly use a Bernoulli distribution instead of a single sample of the Binomial distribution the transformation yields the correct result.

 w = TransformedDistribution[2 x - 1, x \[Distributed] BernoulliDistribution[1/2]]
 PDF[w][Range[-2, 2]]
 {0, 1/2, 0, 1/2, 0}

Mike,

It seems to be a problem of how the PDF function is mapping itself onto a list, rather than a problem with TransformedDistribution.
I get the correct answer with:

PDF[z, #] & /@ Range[-2, 2]
{0, 1/2, 0, 1/2, 0}

Which shows that the PDF function itself is fine. I get the wrong answer even if I do:

 PDF[z, {-1, 0}]
{1/2, 2/\[Pi]}

Cannot say that I understand why. The function description states that it is Listable.

Best,

OL.

Not that this explains why it’s getting the wrong answer but maybe it shows how. Consider

z = TransformedDistribution[2 x - 1,  x \[Distributed] BinomialDistribution[1, 1/2]];
PDF[z]

The output is

PDF[z] output

So when one writes

PDF[z][Range[-2, 2]]

The function is evaluated according to the formula in the output and the formula does not exclude 0 from the range of legitimate values. And plugging zero into that formula gets what you observed for the probability of zero being 2/\pi. As you noticed that things work fine with a Bernoulli with the resulting function being

bernoulli.png

which only allows two positive values (and therefore no errors).

Single values seem to work fine in that the check for an appropriate value occurs. But when a list is given, the formula that shows with PDF[z] is used literally.