# MarginalDistribution with Symbolic range in ProbabilityDistribution

Given the following joint density:

for 10 < x < 20, x/2 < y < x.

To find the marginal density for X we do:

PDF[MarginalDistribution[ProbabilityDistribution[1/25 ((20 - x)/ x),
{x, 10, 20}, {y, x/2, x}], 1], x]


But this does nothing because the range of values for y is dependent on x and non-numeric.

But the marginal density w.r.t x is just the value of the following integral:

Integrate[1/25 ((20 - x)/x ), {y, x/2, x}]


Which correctly gives

(20 - x)/50


If we now change the same for a different distribution with a numerical range:

PDF[MarginalDistribution[ProbabilityDistribution[2/3 (x + 2 y),
{x, 0, 1}, {y, 0, 1}], 1], x]


we get

Which is correct since:

Integrate[2/3 (x + 2 y), {y, 0, 1}]


gives:

2/3 + (2 x)/3


So my question is why doesn't the symbolic range work, if internally Mathematica is just doing the same integration I did above.?

• Played with this for a bit, no luck, my guess is it's one of those not fully realized pieces of the probability functionality. Might be worth a ping to WRI support. – ciao Apr 29 '14 at 4:48
• @rasher, that was my conclusion too. Thanks for taking a crack at it. – RunnyKine Apr 29 '14 at 4:53
• Just as a minor note: 1/25 ((20 - x)/(x y)) should be 1/25 ((20 - x)/(x)) ... though it does not change the substance of the issue you raise. – wolfies Apr 29 '14 at 7:42
• @wolfies. Thanks, I've corrected it. – RunnyKine Apr 29 '14 at 11:06

Comparing with mathStatica output ...

       f  = ((20 - x)/(25*x));
domain[f] = {{x, 10, 20}, {y, x/2, x}};


Then:

works fine, so there does seem to be something odd with the Wolfram algorithm here.

Having said so, the best technique to use when dealing with functions that have dependency in the domain of support (as your example has) is to place all the dependency into the joint pdf itself (the density part) using Boole or Piecewise, so that the domain {{x, 10, 20}, {y, a, b}} part is a rectangular set. For your example, we could enter say:

        g  = ((20-x)/(25x)) * Boole[x/2 < y < x];
domain[g] = {{x, 10, 20}, {y, 0, 20}};


The range of values on y just has to be large enough to cover the full domain of support ... if you don't want to think, simply enter y on the real line {y, -Infinity, Infinity} to cover all cases.

Then:

where I am again using the Marginal function in the mathStatica package for Mathematica. The Wolfram version works fine with this setup:

 PDF[MarginalDistribution[ProbabilityDistribution[g, {x, 10, 20}, {y, 0, 20}], 1], x]


Setting things up this way is a good habit to get into, because it makes it easy to use other Mathematica functions such as Plot3D to plot the joint pdf:

Plot3D[g, {x, 10, 20}, {y, 0, 20}]


Boole allows evaluation:

f[x_, y_] := (20 - x)/(25 x) Boole[x/2 < y < x]
pd = ProbabilityDistribution[
f[x, y], {x, 10, 20}, {y, -Infinity, Infinity}]
PDF[MarginalDistribution[pd, 1], x]


• And it's free! +1 – ciao Jun 25 '17 at 4:56