Group Abstract Group Abstract

Message Boards Message Boards

[?] Solve problem with PDF and discrete variates?

Posted 8 years ago

Can you help me understand why these two plots differ? It seems like in first case variate suddenly stopped being discrete

d1 = TransformedDistribution[x + x, x\[Distributed]DiscreteUniformDistribution[{1,6}]];
DiscretePlot[PDF[d1, {a}], {a,0,15}]

d2 = TransformedDistribution[x + x, {x\[Distributed]DiscreteUniformDistribution[{1,6}], y\[Distributed]DiscreteUniformDistribution[{1,6}]}];
DiscretePlot[PDF[d2, {b}], {b,0,15}]

Thank you.

POSTED BY: Michael Kilburn
8 Replies
POSTED BY: Michael Kilburn

Does this look like a bug to anyone? d1 can be fed into Plot function and it shows uninterrupted line suggesting Wolfram treats it as continuous distribution.

Here is another problem (maybe related) -- here it looks like TransformedDistribution can't apply to itself:

p = DiscreteUniformDistribution[{1,6}];
y = TransformedDistribution[a + b, {a \[Distributed] p, b\[Distributed]p}];
w = TransformedDistribution[c + d, {c \[Distributed] y, d \[Distributed]p}];

pdf1 = PDF[y]
DiscretePlot[pdf1[s1], {s1, 0, 20}, ExtentSize -> 0.8]

pdf2 = PDF[w]
DiscretePlot[pdf2[s2], {s2, 0, 20}, ExtentSize -> 0.8]

pdf2 refuses to be evaluated to anything meaningful (to me).

POSTED BY: Michael Kilburn

For the first problem, use PDF[d1, a] (without the curly brackets around a). Then DiscretePlot[] gives the following output, which looks right to me:

Plot of PDF of twice a discrete uniform variate

For #2, what version of Mathematica are you using? In my copy (which is 11.0.1.0), Here's what I get when running your last two lines:

Plot of iteratively applying TransformedDistribution[]

Thank you for helping me with case #1. Do you reckon it is a bug or I am missing some important distinction between a and {a} in this context?

About case #2 -- I am using Wolfram Programming Lab (free subscription), no idea about backend it uses and version. I need to run few simple calcs involving throwing dices -- ended up spending my evenings for more than a week, fighting weird syntax issues and digging in help pages. :)

Here is what I get when running second part: enter image description here

POSTED BY: Michael Kilburn
POSTED BY: Michael Kilburn

I agree that there seem to be some issues with PDF[], but part of the issue is that computing explicit PDFs of nontrivial distributions is not so easy.

The distributions themselves can be worked with in various ways, even if PDF[] doesn't give you what you want. For example, here are some computations of the mean of d4, the expectation of $e^{-x}$ when $x$ is distributed as d4, and a histogram of a million random samples from d4:

Computations with derived distribution

It is correct, but I must point out that actual amount of underlying computations is minuscule -- we are talking about probability mass function of discrete variable in a very small range ([0, 100] tops). That distribution is defined by array of values no longer than 100 elements -- transforming it (e.g. calculating distribution of Max[x1 - x2, 0]) is trivial convolution of two short arrays, modern CPU can do thousands of these per second.

I suspect Wolfram Lab backend spends all this time in logic that attempts to comprehend and simplify symbolic representation of related functions, but it seems that it is very inefficient. Probably because the same thing PDF is used for both discrete and continuous distributions. Probably a reason behind these bugs too.

POSTED BY: Michael Kilburn
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard