statsmodels/statsmodels — Issue #110: use gammaln instead of log(factorial(.))
Author: josef-pkt
Created: 2011-11-22 02:46:51+00:00
State: open
Labels: comp-discrete

in loglike for example for poisson the use of factorial limits the largest possible observation,
In other cases there are numerical precision problems with factorial (but I don't know or remember a case in statsmodels)

(I had some simulated cases where Poisson fit ended with an exception)

```
>>> from scipy.misc import factorial
>>> factorial(200)
array(inf)
>>> factorial(100)
array(9.3326215443944151e+157)
>>> factorial(50)
array(3.0414093201713381e+64)

>>> np.log(factorial(50))
148.47776695177302
>>> np.log(factorial(200))
inf
>>> np.log(factorial(100))
363.73937555556347

>>> from scipy.special import gammaln
>>> gammaln(50+1)
148.47776695177302
>>> gammaln(200+1)
863.23198719240554
>>> gammaln(100+1)
363.73937555556347
```