3
$\begingroup$
xd = ExponentialDistribution[1.0];
yd = ExponentialDistribution[5.0];
td = TransformedDistribution[x/(x + y), {x \[Distributed] xd, y \[Distributed] yd}];
Mean[td]
CDF[td, z]

All the above works as expected. But when I do

Quantile[td, 0.95]

I get the input echoed as the answer, i.e. MMA can not do this. Same answer in 9 & 10.

Any suggestions? Known bug or am I doing something wrong?

$\endgroup$
4
$\begingroup$

Mathematica does not automatically calculate the quantile (or InverseCDF) for arbitrary distributions. You need to do it.

xd = ExponentialDistribution[1]; (* use exact argument *)
yd = ExponentialDistribution[5]; (* use exact argument *)
td = TransformedDistribution[
   x/(x + y), {x \[Distributed] xd, y \[Distributed] yd}];

quantile[q_] = z /. Solve[{CDF[td, z] == q, 0 <= z <= 1}, z, Reals][[1]]

ConditionalExpression[(5 q)/(1 + 4 q), 0 < q < 1]

quantile[0.95]

0.989583

Plot[quantile[q], {q, 0, 1}]

enter image description here

EDIT: Generalizing the problem:

Clear[\[Lambda]x, \[Lambda]y, td, z]

td[\[Lambda]x_, \[Lambda]y_] = TransformedDistribution[x/(x + y),
   {x \[Distributed] ExponentialDistribution[\[Lambda]x],
    y \[Distributed] ExponentialDistribution[\[Lambda]y]}];

quantile[td[\[Lambda]x_, \[Lambda]y_], q_] =
 z /. Solve[{CDF[td[\[Lambda]x, \[Lambda]y], z] == q, 0 < q < 1},
     z, Reals][[1]] // Simplify[#, {\[Lambda]x > 0, \[Lambda]y > 0}] &

ConditionalExpression[(q*[Lambda]y)/([Lambda]x - q*[Lambda]x + q*[Lambda]y), 0 < q < 1]

({#, z = quantile[td[\[Lambda]x, \[Lambda]y], Rationalize[#]],
      z /. {\[Lambda]x -> 1., \[Lambda]y -> 
         5}} & /@
    {.5, .75, .9, .95, .99} // Simplify) //
 TableForm[#, TableHeadings -> {None,
     {"\nCDF", "quantile,\ni.e.,\ninverse CDF",
      "\n{\[Lambda]x \[Rule] 1,\n \[Lambda]y \[Rule] 5}"}}] &

enter image description here

$\endgroup$
  • 1
    $\begingroup$ It is correct that Mathematica will not give a symbolic closed form of the InverseCDF for an arbitrary distribution, if it doesn't exist. But isn't Mathematica supposed to give a numarical value for, in this example, InverseCDF[td,0.95]? $\endgroup$ – Karsten 7. Jul 22 '14 at 16:28
  • $\begingroup$ @Karsten7 - Mathematica only knows what it has been told and they have elected not to tell it how to do this. For this distribution there is a closed form for the inverse CDF (quantile above) but it does not know this a priori and hasn't been told to try. Presumably because in many/most cases it might spend a lot of time and still fail; and for those cases where it will work you can easily do it. $\endgroup$ – Bob Hanlon Jul 22 '14 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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