You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2023/04/02 11:13:00 UTC

[jira] [Comment Edited] (NUMBERS-167) RegularizedGamma.P with precomputed LogGamma value

    [ https://issues.apache.org/jira/browse/NUMBERS-167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17707639#comment-17707639 ] 

Gilles Sadowski edited comment on NUMBERS-167 at 4/2/23 11:12 AM:
------------------------------------------------------------------

{quote} As for your use case, I can see that it is a benefit to precompute the log gamma value for repeat calls. However I cannot say how much the performance gain will be without getting refamiliar with all the code. I think this change would also be of benefit to a few of the Statistics distributions.
{quote}
It turns out that the function was used to compute the [Χ{^}2{^} distribution|https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/javadocs/api-1.0/org/apache/commons/statistics/distribution/ChiSquaredDistribution.html]'s inverse cumulative probability. The latter currently calls {{inverse cumulative probability}} in class [{{GammaDistribution}}|https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/javadocs/api-1.0/org/apache/commons/statistics/distribution/GammaDistribution.html] that uses the default implementation in [{{AbstractContinuousDistribution}}|https://gitbox.apache.org/repos/asf?p=commons-statistics.git;a=blob_plain;f=commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/AbstractContinuousDistribution.java;hb=HEAD]. Doesn't it entail that it is quite likely that is much slower and potentially less accurate than what is implemented in that other library?

Note: There seems to be an issue with the generated API docs [at this page|https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/javadocs/api-1.0/org/apache/commons/statistics/distribution/GammaDistribution.html#inverseCumulativeProbability-double-] (the [link to the code of {{inverseCumulativeProbability}}|https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/javadocs/api-1.0/src-html/org/apache/commons/statistics/distribution/AbstractContinuousDistribution.html#line.129] returns "Not Found"). This is probably because {{AbstractContinuousDistribution}} is not in the public API.



was (Author: erans):
bq.  As for your use case, I can see that it is a benefit to precompute the log gamma value for repeat calls. However I cannot say how much the performance gain will be without getting refamiliar with all the code. I think this change would also be of benefit to a few of the Statistics distributions.

It turns out that the function was used to compute the [&Chi;^2^ distribution|https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/javadocs/api-1.0/org/apache/commons/statistics/distribution/ChiSquaredDistribution.html]'s inverse cumulative probability. The latter currently calls {{inverse cumulative probability}} in class [{{GammaDistribution}}|https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/javadocs/api-1.0/org/apache/commons/statistics/distribution/GammaDistribution.html] that uses the default implementation in [{{AbstractContinuousDistribution}}|https://gitbox.apache.org/repos/asf?p=commons-statistics.git;a=blob_plain;f=commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/AbstractContinuousDistribution.java;hb=HEAD].  Doesn't it entail that it is quite likely that is much slower and potentially less accurate than what is implemented in that other library?

Note: There seems to be an issue with the generated API docs [at this page|https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/javadocs/api-1.0/org/apache/commons/statistics/distribution/GammaDistribution.html#inverseCumulativeProbability-double-] (the [link to the code of {{inverseCumulativeProbability}}|https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/javadocs/api-1.0/src-html/org/apache/commons/statistics/distribution/AbstractContinuousDistribution.html#line.129] returns "Not Found").

> RegularizedGamma.P with precomputed LogGamma value
> --------------------------------------------------
>
>                 Key: NUMBERS-167
>                 URL: https://issues.apache.org/jira/browse/NUMBERS-167
>             Project: Commons Numbers
>          Issue Type: Wish
>          Components: gamma
>            Reporter: Gilles Sadowski
>            Priority: Minor
>             Fix For: 1.2
>
>         Attachments: pr_106.patch
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> We have
> {code:java}
> double v = RegularizedGamma.P.value(a, x);
> {code}
> where method {{value}} internally calls {{LogGamma.value(a)}}.
> There is a use-case for
> {code:java}
> double logGammaA = LogGamma.value(a);
> double v = RegularizedGamma.P.value(a, x, logGammaA);
> {code}
> for when the user varies {{x}} but not {{a}}.
> Method name TBD:  Another overload of {{value}} may be confusing (?).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)