Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Math::NumberCruncher-5.00 bug

Reply
Thread Tools

Math::NumberCruncher-5.00 bug

 
 
WCR.III@gmail.com
Guest
Posts: n/a
 
      01-14-2005

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:



> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM
ASP.NET Login control bug or SQL 2005 bug? RedEye ASP .Net 2 12-13-2005 10:57 AM
Re: BUG? OR NOT A BUG? John ASP .Net 2 09-21-2005 10:31 AM
Bug Parade Bug 4953793 Michel Joly de Lotbiniere Java 4 12-02-2003 05:05 AM
how to report bug to g++ ? got a bug and fixed up source code DarkSpy C++ 4 06-27-2003 09:05 AM



Advertisments