Closed Hypercubed closed 8 years ago
That would probably be too specialised to be included, but you are welcome to post it here. Perhaps mathjs would be interested, as it uses this library under the hood.
math.js has an implementation of the gamma function. The number
implementation uses the Lanczos approximation for small values, and an extended Stirling approximation for large values. The BigNumber
(decimal.js) implementation only supports integers and still has to be extended with support for non-integer input, so @Hypercubed you could contribute there.
Here is the concerning sourcecode: https://github.com/josdejong/mathjs/blob/master/lib/function/probability/gamma.js
Hi @josdejong , actually my implementation of the Lanczos approximation in decimal.js was created by looking closely at the math.js complex gamma function (as well as wikipedia and https://github.com/substack/gamma.js). I was attempting to make a Big-Complex gamma function, and that, in turn, required a decimal.js gamma function.
However, this morning I realized that the result is not precise. The approximation is limited to the precision of the coefficients. Implementing arbitrary precision Chebyshev polynomials looks painful.
ah ok. Well, thanks anyway. Maybe some day if you feel like it ;)
I'll keep working on it. From what I have seen in various resources online it's not an easy problem. I have some hopes for this: http://www.ebyte.it/library/downloads/2007_MTH_Nemes_GammaFunction.pdf
If I come up with anything I'll do a PR at math.js.
Would you consider a PR for a gamma function implementation? I have a Decimal.js gamma function implemented using the Lanczos approximation.