17
$\begingroup$

Bug Introduced in 11.3 or earlier

Initial testing indicates this has been addressed in 12.0

Observe:

d1 = UniformDistribution[{0, k}];
d2 = ProbabilityDistribution[1/k, {x, 0, k}];


FullSimplify[PDF[d2, w] == PDF[d1, w], k > w > 0]
FullSimplify[CDF[d2, w] == CDF[d1, w], k > w > 0]

True

True

Mean[OrderDistribution[{#, n}, 1]] & /@ {d1, d2}
SameQ @@ %

{k/(1 + n), k/(1 + n)}

True

All good and correct.

Now (note n in above is explicitly a value here):

Mean[OrderDistribution[{#, 2}, 1]] & /@ {d1, d2}
SameQ @@ %

{k/3, 0}

False

The latter result list for Mean should have the same values.

Bug, or am I missing something obvious?

(11.3 Windows 10)

Update: Motivated by Wolfies' answer (I could not believe MMA did not take into account the domain), observe:

(* FRESH KERNEL START *)
d3 = ProbabilityDistribution[1/k, {x, 0, k}, Assumptions -> k > 0];

(*PDF[OrderDistribution[{d3,2},1],x]*)

Mean[OrderDistribution[{d3, 2}, 1]]

0

Clearly incorrect.

Now:

d3 = ProbabilityDistribution[1/k, {x, 0, k}, Assumptions -> k > 0];

PDF[OrderDistribution[{d3,2},1],x]

Mean[OrderDistribution[{d3, 2}, 1]]

k/3

Correct of course. But the only difference is the use of PDF function between distribution definition and Mean functions. This obviously should have no effect.

The assertion that "The way to resolve all this is to add an assumption on the parameter when defining the original parent pdf" is incorrect: The results above remain with or without the superfluous addition of the assumptions.

You don't even need a clean Kernel - just comment in/out the PDF call and the end result changes

So it seems something even stranger is going on...

$\endgroup$
  • 2
    $\begingroup$ d2 = ProbabilityDistribution[1./k, {x, 0, k}] seems to fix it. Look like a bug, though. $\endgroup$ – Michael E2 Dec 14 '18 at 15:22
  • $\begingroup$ @MichaelE2 - yep, makes symbolic use touch-and-go - I had a result in a much more complex scenario that looked fishy, tracked it down to this issue, made simpler example for OP. Tagged as bug. $\endgroup$ – ciao Dec 14 '18 at 19:06
3
$\begingroup$

Part of the problem here is working with black boxes, and not checking the output at each stage.

We are given $X \sim \text{Uniform}(0,k)$ which the OP has entered as:

  d2 = ProbabilityDistribution[1/k, {x, 0, k}]

Then, the OP seeks the pdf of the 1st order statistic, in a sample of size 2, which he evaluates as:

 OrderDistribution[{d2, 2}, 1]

... which returns the black box:

OrderDistribution[{ProbabilityDistribution[1/k, {[FormalX], 0, k}], 2}, 1]

However, if we check the pdf returned ...

PDF[OrderDistribution[{d2, 2}, 1], x]

enter image description here

... then we see what the problem is: the OP has not specified that the constant $k$ is positive, and while this could be readily assumed, Mathematica has not assumed it, and instead produced a piecewise function that gives different outputs, depending on whether $k>0$ or $k<0$ (which is not necessarily meaningful in this context) and the end result has multiple and unintended meanings that does not represent a well-defined pdf.

Resolution

The way to resolve all this is to add an assumption on the parameter when defining the original parent pdf: i.e.

 d3 = ProbabilityDistribution[1/k, {x, 0, k}, Assumptions -> k > 0]

Then:

 PDF[OrderDistribution[{d3, 2}, 1], x]

enter image description here

.. and all is well. Then:

Mean[OrderDistribution[{d3, 2}, 1]]

k/3

mathStatica comparison

As comparison, using the mathStatica add-on package (which, as disclosure, I am one of the authors), the pdf can be entered either with or without the assumption on $k$:

 f = 1/k;        domain[f] = {x, 0, k}  && {k > 0};

... and the pdf of the 1st order statistic, in a sample of size 2, is returned, in both cases, as:

 OrderStat[1, f, 2]

enter image description here

.. with the same domain of support as the parent.

$\endgroup$
  • 1
    $\begingroup$ It's not that simple. In fact, it's even stranger and clearly something wacky - see my updated OP. $\endgroup$ – ciao Dec 15 '18 at 21:33
  • 1
    $\begingroup$ I must agree. On further evaluation, starting from a fresh kernel, evaluating: ............................ d3 = ProbabilityDistribution[1/k, {x, 0, k}, Assumptions -> k > 0]; And then: Mean[OrderDistribution[{d3, 2}, 1]] ... Then: .............................. PDF[OrderDistribution[{d3, 2}, 1], x] returns 0 ... which is very wacky. $\endgroup$ – wolfies Dec 16 '18 at 10:27

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.