Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Fastest way to calculate hypergeometric distribution probabilities (i.e. BIG factorials)?

by Zaxo (Archbishop)
on Jun 14, 2005 at 04:51 UTC ( [id://466381]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Fastest way to calculate hypergeometric distribution probabilities (i.e. BIG factorials)?
in thread Fastest way to calculate hypergeometric distribution probabilities (i.e. BIG factorials)?

Good idea, but no cigar.

$ perl -MMath::Gsl::Sf=:Gamma -e'print gamma(300)' gsl: gamma.c:1111: ERROR: overflow Default GSL error handler invoked. Aborted (core dumped) $
The GSL doesn't handle large numbers.

There's also a math error to correct: gamma($n) == factorial($n - 1)

After Compline,
Zaxo

  • Comment on Re^3: Fastest way to calculate hypergeometric distribution probabilities (i.e. BIG factorials)?
  • Select or Download Code

Replies are listed 'Best First'.
Re^4: Fastest way to calculate hypergeometric distribution probabilities (i.e. BIG factorials)?
by salva (Canon) on Jun 14, 2005 at 08:15 UTC
    if your calculations over the factorial numbers are only multiplications and divisions (as I think they are), you can operate over their log values instead, transforming multiplications and divisions to additions and substractions respectively. i.e.:
    log ($n! / ($r! * ($n-$r)!) = Sum(log(1)..log($n)) - Sum(log(1)..log($r)) - Sum(log(1)..log($n-$r))
    and as your operations will only involve a small number of integers, you can cache log($n) and log($n!) to speed up the calculations.
Re^4: Fastest way to calculate hypergeometric distribution probabilities (i.e. BIG factorials)?
by mrborisguy (Hermit) on Jun 14, 2005 at 13:05 UTC

    Really... all along I thought gamma was equal to the factorial. That's new to me, thanks!

        -Bryan

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://466381]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-25 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found