Commons Math
  1. Commons Math
  2. MATH-692

Cumulative probability and inverse cumulative probability inconsistencies

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0, 1.1, 1.2, 2.0, 2.1, 2.2, 3.0
    • Fix Version/s: 3.0
    • Labels:
      None

      Description

      There are some inconsistencies in the documentation and implementation of functions regarding cumulative probabilities and inverse cumulative probabilities. More precisely, '<' and '<=' are not used in a consistent way.

      Besides I would move the function inverseCumulativeProbability(double) to the interface Distribution. A true inverse of the distribution function does neither exist for Distribution nor for ContinuosDistribution. Thus we need to define the inverse in terms of quantiles anyway, and this can already be done for Distribution.

      On the whole I would declare the (inverse) cumulative probability functions in the basic distribution interfaces as follows:

      Distribution:

      • cumulativeProbability(double x): returns P(X <= x)
      • cumulativeProbability(double x0, double x1): returns P(x0 < X <= x1) [see also 1)]
      • inverseCumulativeProbability(double p):
        returns the quantile function inf {x in R | P(X<=x) >= p}

        [see also 2), 3), and 4)]

      1) An aternative definition could be P(x0 <= X <= x1). But this requires to put the function probability(double x) or another cumulative probability function into the interface Distribution in order be able to calculate P(x0 <= X <= x1) in AbstractDistribution.
      2) This definition is stricter than the definition in ContinuousDistribution, because the definition there does not specify what to do if there are multiple x satisfying P(X<=x) = p.
      3) A modification could be defined for p=0: Returning sup

      {x in R | P(X<=x) = 0}

      would yield the infimum of the distribution's support instead of a mandatory -infinity.
      4) This affects issue MATH-540. I'd prefere the definition from above for the following reasons:

      • This definition simplifies inverse transform sampling (as mentioned in the other issue).
      • It is the standard textbook definition for the quantile function.
      • For integer distributions it has the advantage that the result doesn't change when switching to "x in Z", i.e. the result is independent of considering the intergers as sole set or as part of the reals.

      ContinuousDistribution:
      nothing to be added regarding (inverse) cumulative probability functions

      IntegerDistribution:

      • cumulativeProbability(int x): returns P(X <= x)
      • cumulativeProbability(int x0, int x1): returns P(x0 < X <= x1) [see also 1) above]
      1. MATH-692_integerDomain_patch1.patch
        55 kB
        Christian Winter
      2. Math-692_realDomain_patch1.patch
        26 kB
        Christian Winter

        Activity

        Gilles made changes -
        Affects Version/s 2.2.1 [ 12316402 ]
        Gilles made changes -
        Affects Version/s 1.3 [ 12313042 ]
        Thomas Neidhart made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Sébastien Brisard made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Sébastien Brisard made changes -
        Comment [ The committed patch actually causes failure of {{Well1024Test}} in {{o.a.c.m.random}}. ]
        Christian Winter made changes -
        Attachment MATH-692_integerDomain_patch1.patch [ 12507992 ]
        Christian Winter made changes -
        Attachment Math-692_realDomain_patch1.patch [ 12502956 ]
        Christian Winter made changes -
        Field Original Value New Value
        Priority Major [ 3 ] Minor [ 4 ]
        Christian Winter created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Christian Winter
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development