W
WCR.III
Just a note to stuff this into the 'net consciousness, since I
can't find it mentioned anywhere else.
The SignSignificance calculation in Math::NumberCruncher
has a bug.
currently the code looks like this:
Unfortunately, the confidence isn't calculated properly - the
middle operand to Binomial needs to iterate from $hits to $trials.
To fix, do something like this instead:
Yes, it's clunky and looks like C by Perl standards. It also
doesn't have bugs introduced because implied automatic
variables are being (mis) used
I informed the module maintainer of this problem some time
ago, but a recent re-install of the module demonstrated that
the fix hadn't made it into the code yet.
Just another C hacker...
Will Ray
can't find it mentioned anywhere else.
The SignSignificance calculation in Math::NumberCruncher
has a bug.
currently the code looks like this:
my ( $trials, $hits, $probability ) = @_;
return undef unless defined $trials && defined $hits &&
defined $probability;
my $confidence;
foreach ( $hits .. $trials ) {
$confidence += Binomial( $trials, $hits, $probability );
}
return $confidence;
Unfortunately, the confidence isn't calculated properly - the
middle operand to Binomial needs to iterate from $hits to $trials.
To fix, do something like this instead:
my ( $trials, $hits, $probability ) = @_;
return undef unless defined $trials && defined $hits &&
defined $probability;
my ($confidence, $ahit, $aconf);
$confidence = 0;
foreach ($ahit = $hits;$ahit <= $trials;$ahit++)
{
$aconf = Binomial( $trials, $ahit, $probability );
# print STDERR "numcrunch binomial returns: $hits $ahit $trials $aconf\n";
$confidence += $aconf;
}
return $confidence;
Yes, it's clunky and looks like C by Perl standards. It also
doesn't have bugs introduced because implied automatic
variables are being (mis) used
I informed the module maintainer of this problem some time
ago, but a recent re-install of the module demonstrated that
the fix hadn't made it into the code yet.
Just another C hacker...
Will Ray