[
https://issues.apache.org/jira/browse/NUMBERS-167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17382896#comment-17382896
]
Alex Herbert commented on NUMBERS-167:
--------------------------------------
If the 'a' and 'logGammaA' are coupled then it seems that a method to accept
them should accept them as a coupled item:
{code:java}
static class LogGammaTerm {
final double a;
final double logGammaA;
LogGammaTerm(double a) {
this.a = a;
this.logGammaA = LogGamma.value(a);
}
}
LogGammaTerm t = new LogGammaTerm(a);
double v = RegularizedGamma.P.value(t, x);
{code}
The alternative is leaving the user to be aware of what they are doing. If
using a precomputed term then the method name of {{value}} is not as confusing.
Looking at the code the LogGamma.value(a) is only part of the computation for
RegularizedGamma.P (and Q). The rest is a continued fraction evaluation. So
this may require a performance test to check the proportion of the computation
that is attributed to each part. This is mainly out of interest. LogGamma.value
does appear to do a lot of work so eliminating this call will have a noticeable
effect even if it is only 10% of the computation.
> 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.1
>
>
> 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.3.4#803005)