in reply to Fast hypergeometric calculation in Perl

Besides BrowserUk suggestion (that's probably the way to go), some simple modifications on logfact (inlining things and eliminating unnecessary temporaries) makes it twice as fast:
sub hypergeom1 { # There are m "bad" and n "good" balls in an urn. # Pick N of them. The probability of i or more successful selectio +ns: # (m!n!N!(m+n-N)!)/(i!(n-i)!(m+i-N)!(N-i)!(m+n)!) my ($n, $m, $N, $i) = @_; my $loghyp1 = logfact1($m) +logfact1($n)+logfact1($N)+logfact1($m+ +$n-$N); my $loghyp2 = logfact1($i)+logfact1($n-$i)+logfact1($m+$i-$N)+logf +act1($N-$i)+logfact1($m+$n); return exp($loghyp1 - $loghyp2); } sub logfact1 { my $x = shift; my $ser = ( 1.000000000190015 + 76.18009172947146 / ($x + 2) - 86.50532032941677 / ($x + 3) + 24.01409824083091 / ($x + 4) - 1.231739572450155 / ($x + 5) + 0.12086509738661e-2 / ($x + 6) - 0.5395239384953e-5 / ($x + 7) ); my $tmp = $x + 6.5; ($x + 1.5) * log($tmp) - $tmp + log(2.5066282746310005 * $ser / ($ +x+1)); }