You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex Herbert (Jira)" <ji...@apache.org> on 2021/09/21 15:11:00 UTC

[jira] [Updated] (STATISTICS-34) Geometric distribution to switch PMF computation for increased accuracy

     [ https://issues.apache.org/jira/browse/STATISTICS-34?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alex Herbert updated STATISTICS-34:
-----------------------------------
    Description: 
The Geometric distribution is defined by the probability of success (p).

The PMF is:
{noformat}
pmf(x) = pow(1 - p, x) * p
{noformat}
This can be implemented directly or using exponential functions:
{code:java}
double p1 = Math.pow(1.0 - p, x) * p;
double p2 = Math.exp(Math.log1p(-p) * x) * p;
{code}
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.

  was:
The Geometric distribution is define by the probability of success (p).

The PMF is:
{noformat}
pmf(x) = pow(1 - p, x) * p
{noformat}

This can be implemented directly or using exponential functions:

{code:java}
double p1 = Math.pow(1.0 - p, x) * p;
double p2 = Math.exp(Math.log1p(-p) * x) * p;
{code}

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.



> Geometric distribution to switch PMF computation for increased accuracy
> -----------------------------------------------------------------------
>
>                 Key: STATISTICS-34
>                 URL: https://issues.apache.org/jira/browse/STATISTICS-34
>             Project: Apache Commons Statistics
>          Issue Type: Improvement
>          Components: distribution
>    Affects Versions: 1.0
>            Reporter: Alex Herbert
>            Priority: Trivial
>             Fix For: 1.0
>
>
> The Geometric distribution is defined by the probability of success (p).
> The PMF is:
> {noformat}
> pmf(x) = pow(1 - p, x) * p
> {noformat}
> This can be implemented directly or using exponential functions:
> {code:java}
> double p1 = Math.pow(1.0 - p, x) * p;
> double p2 = Math.exp(Math.log1p(-p) * x) * p;
> {code}
> 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)