Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Given the following joint density:

Mathematica graphics

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

Mathematica graphics

Which is correct since:

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


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.?

share|improve this question
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. –  rasher Apr 29 at 4:48
@rasher, that was my conclusion too. Thanks for taking a crack at it. –  RunnyKine Apr 29 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 at 7:42
@wolfies. Thanks, I've corrected it. –  RunnyKine Apr 29 at 11:06

1 Answer 1

up vote 5 down vote accepted

Comparing with mathStatica output ...

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


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.


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}]

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.