Uploaded image for project: 'Commons Statistics'
  1. Commons Statistics
  2. STATISTICS-34

Geometric distribution to switch PMF computation for increased accuracy

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 1.0
    • 1.0
    • distribution
    • None

    Description

      The Geometric distribution is defined by the probability of success (p).

      The PMF is:

      pmf(x) = pow(1 - p, x) * p
      

      This can be implemented directly or using exponential functions:

      double p1 = Math.pow(1.0 - p, x) * p;
      double p2 = Math.exp(Math.log1p(-p) * x) * p;
      

      The current code uses exponential functions. Implementations in Matlab, R and SciPy all use the power function. Both have advantages depending on the value of p.

      When p is >= 0.5 the value (1-p) is exact. As p becomes increasingly small then (1-p) loses precision due to the limited precision of a double value close to 1.

      Attachments

        Activity

          People

            Unassigned Unassigned
            aherbert Alex Herbert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: