6
$\begingroup$

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

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

$\endgroup$
4
  • $\begingroup$ 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. $\endgroup$
    – ciao
    Apr 29, 2014 at 4:48
  • $\begingroup$ @rasher, that was my conclusion too. Thanks for taking a crack at it. $\endgroup$
    – RunnyKine
    Apr 29, 2014 at 4:53
  • $\begingroup$ 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. $\endgroup$
    – wolfies
    Apr 29, 2014 at 7:42
  • $\begingroup$ @wolfies. Thanks, I've corrected it. $\endgroup$
    – RunnyKine
    Apr 29, 2014 at 11:06

2 Answers 2

6
$\begingroup$

Comparing with mathStatica output ...

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

Then:

enter image description here

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:

enter image description here

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

enter image description here

$\endgroup$
0
2
$\begingroup$

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]

enter image description here

$\endgroup$
1
  • $\begingroup$ And it's free! +1 $\endgroup$
    – ciao
    Jun 25, 2017 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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