Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Thank-you: that was exactly the problem. Merely replacing Math::Big::factorial with Math::BigFloat::bfac fixed it. The code's below for posterity's sake:

use strict; use Math::BigFloat; my $G = 11057; #$ARGV[0]; my $C = $ARGV[0]; my $n = $ARGV[1]; my $k = $ARGV[2]; sub choose { my $ret_val = Math::BigFloat->new(); my $n = Math::BigFloat->new($_[0]); my $r = Math::BigFloat->new($_[1]); my $n_r = Math::BigFloat->new($_[0] - $_[1]); $n->bfac(); $r->bfac(); $n_r->bfac(); $ret_val = $n / ($n_r * $r); return $ret_val; } my $p = Math::BigFloat->new('1'); my $denom = Math::BigFloat->new(choose($G, $n)); for (my $i = 0; $i < $k; $i++) { my $val1 = $G - $C; my $val2 = $n - $i; my $delta = Math::BigFloat->new(); $delta = choose($C, $i) * choose($val1, $val2) / $denom; $p -= $delta; } print "Probability estimate: $p\n";

In reply to Re: Re: Hypergeometric Probability Calculation by Itatsumaki
in thread Hypergeometric Probability Calculation by Itatsumaki

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (6)
    As of 2020-12-02 00:18 GMT
    Find Nodes?
      Voting Booth?
      How often do you use taint mode?

      Results (25 votes). Check out past polls.