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

Amey Jadiye commented on NUMBERS-38:
------------------------------------

Hi [~erans]

bq. It is still not clear to me what is the benefit of moving those lines ... 
Let me try to put this way .. Gamma is nothing but advanced factorial function 
with advantages like we can have factorial of whole numbers as well as 
factional. Now [Gamma function| https://en.wikipedia.org/wiki/Gamma_function] 
which is having general formula {{Gamma( x ) = integral( t^(x-1) e^(-t), t = 0 
.. infinity)}} and Lanczos approximation / Stirling's approximation /Spouge's 
Approximation  *is a* gamma function so they should be extend Gamma.

Exact algorithm and formulas here :
 - [Lanczo's Approximation|https://en.wikipedia.org/wiki/Lanczos_approximation]
 - [Stirling's 
Approximation|https://en.wikipedia.org/wiki/Stirling%27s_approximation]
 - [Spouge's 
Approximation|https://en.wikipedia.org/wiki/Spouge%27s_approximation]

Why to refactor code is because basic gamma computes not so accurate values so 
someone who need quick computation without precision can choose it, while 
someone who need precision overs cost of performance _(Lanczos approximation is 
accurate so its slow)_ can choose which algorithm they want which is not 
possible right now.

I'm proposing something like:
{quote}
Gamma gammaFun = new Gamma(); gammaFun.value( x );
Gamma gammaFun = new LanczosGamma(); gammaFun.value( x );
Gamma gammaFun = new StirlingsGamma(); gammaFun.value( x );
Gamma gammaFun = new SpougesGamma(); gammaFun.value( x );
{quote}

as the class name suggestion {{LanczosApproximation}} it should execute full 
_Lanczos Algoritham_ but we are just computing coefficients in that class which 
is incorrect, so just refactoring is needed which wont break any dependency of 
this class anywhere.

All that said, will do 2 things now.

# I will propose this to commons-dev mailing list and lets see what others are 
thinking about this ?
# I will change the PR code and will make test cases just to test what 
coefficients are we generating with against 2 codes I found on internet._(which 
is you are suggesting)_

So if proposal fails we will have test cases anyway for existing code *or* if 
proposal passes will create other JIRA and modify test cases according to 
different algorithms.

let me know your thoughts?


> No unit tests for "LanczosApproximation" class
> ----------------------------------------------
>
>                 Key: NUMBERS-38
>                 URL: https://issues.apache.org/jira/browse/NUMBERS-38
>             Project: Commons Numbers
>          Issue Type: Test
>            Reporter: Gilles
>              Labels: unit-test
>             Fix For: 1.0
>
>         Attachments: NUMBERS-38.patch
>
>
> The computation of the {{LanczosApproximation}} (package 
> {{o.a.c.numbers.gamma}} in module {{commons-numbers-gamma}}) function is not 
> checked by unit tests.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to