I would like to evaluate the PDF of a custom ProbabilityDistribution at the min and max values. However, PDF[...] returns 0 at the boundary conditions. Is there an elegant way to prevent this? Example:

dst = ProbabilityDistribution[2 x, {x, 0, 1}];
PDF[dst, 0.99999] (* = 1.99998 *)
PDF[dst, 1] (* = 0 *) (* I would like this to return 2 *)

The docs say that

the pdf is taken to be zero for $x < x_{min}$ and $x > x_{max}$

It seems inconsistent that the PDF is forced to zero at $x = x_{max}$.

  • 2
    $\begingroup$ It's either a bug in the definition or incorrect documentation. Implementation wise, it is definitely defined only for $x_{min}<x<x_{max}$ and not for $x_{min}\le x\le x_{max}$. For example, see what this gives you: PDF[ProbabilityDistribution[f, {x, 0, 1}], x] $\endgroup$ – rm -rf Aug 1 '12 at 7:58
  • $\begingroup$ Does it have impact on any of your calculations? I don't think it will matter at all, so why care? Plot[PDF[dst, x], {x, -1, 2}, ExclusionsStyle -> Directive[Gray, Dashed]]does exactly what you would expect. Same for Integrate[PDF[dst, x], {x, -\[Infinity], \[Infinity]}] $\endgroup$ – Sjoerd C. de Vries Aug 1 '12 at 9:04
  • 1
    $\begingroup$ Knowing of this issue you can use e.g. Limit[PDF[dst, x], x -> 1 , Direction -> 1] and Limit[PDF[dst, x], x -> 0 , Direction -> -1] to get 2 or 0 respectively. $\endgroup$ – Artes Aug 1 '12 at 9:35
  • $\begingroup$ Side note: the PDF you used in ProbabilityDistribution is not normalized. This is known to cause various functions to silently return incorrect results. $\endgroup$ – Szabolcs Feb 22 '14 at 0:08

Your Answer

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

Browse other questions tagged or ask your own question.