You could get more accuracy from the Math::Pari version if you did the powers and multiplies on the Pari side and didn't use logs:

`sub binomial_pari {
my ($k, $n, $p) = @_;
my $first = binomial($n,$k);
# gpui is imported from Math::Pari. It is x ** y.
my $second = gpui($p,$k);
my $third = gpui(1.0 - $p, $n - $k);
my $Prob = $first * $second * $third;
return $Prob;
}
`

Here are the different results I get:

`Sub Binom Comb = 0.3125
Sub Binom Log = 0.3125000000000001128
Sub Binom Pari = 0.3125000000000000000
`

Comment onRe: Getting Binomial Distribution under Math::Pari (log) and Combinatorial MethodSelectorDownloadCode