josef.pktd | 11 Oct 00:58 2012
Picon

special: beta or gamma

scipy.stats has a bit of a mixed usage
in most cases we use gammaln to get higher precision, but maybe betaln
would be better

>>> factorial(30) / factorial(5) / factorial(25)
142506.0
>>> 1./special.beta(6, 26) / 31
142505.99999999997
>>> special.gamma(31) / special.gamma(6) / special.gamma(26)
142506.0

>>> np.log(factorial(30) / factorial(5) / factorial(25))
11.867139383067599
>>> -special.betaln(6, 26) - np.log( 31)
11.867139383067599
>>> special.gammaln(31) - special.gammaln(6) - special.gammaln(26)
11.867139383067581

or maybe there is no difference

>>> n1, n2 = 5000, 4000
>>> -special.betaln(n1+1, n2+1) - np.log(n1 + n2 + 1)
6177.8820911143594
>>> special.gammaln(n1+n2+1) - special.gammaln(n1+1) - special.gammaln(n2+1)
6177.8820911143594

>>> n1, n2 = 50000, 4000
>>> special.gammaln(n1+n2+1) - special.gammaln(n1+1) - special.gammaln(n2+1)
14253.783294794481
>>> -special.betaln(n1+1, n2+1) - np.log(n1 + n2 + 1)
(Continue reading)


Gmane