gamma-function

How to make a function that computes the factorial for numbers with decimals?

家住魔仙堡 提交于 2020-01-01 04:43:10
问题 How can I make a function that calculates the factorial (or the gamma function) of decimal numbers in JavaScript? For example, how could I calculate 2.33! ? 回答1: I might have found an existing solution... It's an implementation of Lanczos method, I found it at the swedish wikipedia (http://sv.wikipedia.org/wiki/Gammafunktionen). It was written in python and says to be correct up to 15 decimals. I ported it to js, cross checked some random values against (http://www.efunda.com/math/gamma

Simple approximation of Inverse Incomplete gamma function

醉酒当歌 提交于 2019-12-22 10:12:29
问题 How could one approximate Inverse Incomplete gamma function Г(s,x) by some simple analytical function f(s,Г)? That means write something like x = f(s,Г) = 12*log(123.45*Г) + Г + 123.4^s . (I need at least ideas or references.) 回答1: You can look at the code in Boost: http://www.boost.org/doc/libs/1_35_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/igamma.html and see what they're using. EDIT: They also have inverses: http://www.boost.org/doc/libs/1_35_0/libs/math/doc/sf_and

Fast algorithm for log gamma function

老子叫甜甜 提交于 2019-12-11 07:54:27
问题 I am trying to write a fast algorithm to compute the log gamma function. Currently my implementation seems naive, and just iterates 10 million times to compute the log of the gamma function (I am also using numba to optimise the code). import numpy as np from numba import njit EULER_MAS = 0.577215664901532 # euler mascheroni constant HARMONC_10MIL = 16.695311365860007 # sum of 1/k from 1 to 10,000,000 @njit(fastmath=True) def gammaln(z): """Compute log of gamma function for some real positive

Simple approximation of Inverse Incomplete gamma function

半腔热情 提交于 2019-12-05 18:45:21
How could one approximate Inverse Incomplete gamma function Г(s,x) by some simple analytical function f(s,Г)? That means write something like x = f(s,Г) = 12*log(123.45*Г) + Г + 123.4^s . (I need at least ideas or references.) You can look at the code in Boost: http://www.boost.org/doc/libs/1_35_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/igamma.html and see what they're using. EDIT: They also have inverses: http://www.boost.org/doc/libs/1_35_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/igamma_inv.html I've found out that x = f(s,Г) with given s can be

How to make a function that computes the factorial for numbers with decimals?

帅比萌擦擦* 提交于 2019-12-03 12:40:58
How can I make a function that calculates the factorial (or the gamma function ) of decimal numbers in JavaScript? For example, how could I calculate 2.33! ? I might have found an existing solution... It's an implementation of Lanczos method, I found it at the swedish wikipedia ( http://sv.wikipedia.org/wiki/Gammafunktionen ). It was written in python and says to be correct up to 15 decimals. I ported it to js, cross checked some random values against ( http://www.efunda.com/math/gamma/findgamma.cfm ). http://jsfiddle.net/Fzy9C/ var g = 7; var C = [0.99999999999980993, 676.5203681218851, -1259