Math::NumberCruncher-5.00 bug

Discussion in 'Perl Misc' started by WCR.III@gmail.com, Jan 14, 2005.

  1. Guest

    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
     
    , Jan 14, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chirs
    Replies:
    18
    Views:
    793
    Chris Uppal
    Mar 2, 2004
  2. AciD_X
    Replies:
    4
    Views:
    8,151
    Jonathan Turkanis
    Apr 1, 2004
  3. Mark Healey
    Replies:
    7
    Views:
    1,538
    Tim Prince
    May 22, 2006
  4. Replies:
    2
    Views:
    106
  5. VK
    Replies:
    15
    Views:
    1,278
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page