Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Aloha,

I could really use some help. I have the fun task of converting Splus code to Perl. All has worked beautifully so far the majority of the project. But I am stuck now. I am trying to find out if Perl has a library module for the cumulative probability for the Hypergeometric discrete distribution. Even if such a thing does not exist, perhaps someone has already invented this wheel?

In Splus, the bit of code is: phyper(q, m, n, k)

where:

q: the number of red balls out of a sample of size k drawn from an urn containing m red balls and n black ones.

m: number of red balls in the urn.

n: number of black balls in the urn.

k: number of balls drawn from an urn with m red and n black balls.

I have been searching the web with no luck!

Any help would be greatly appreciated!
Aloha,
Annette

Replies are listed 'Best First'.
Re: Hypergeometric Distribution
by kyle (Abbot) on Aug 11, 2008 at 21:45 UTC

    Searching CPAN for hypergeometric turns up a couple of things that look promising. Would any of those work for you?

Re: Hypergeometric Distribution
by Khen1950fx (Canon) on Aug 11, 2008 at 21:48 UTC
      I think I posted this as a comment instead of a reply ... not sure if that matters .. sorry for duplicates ... Thank you so much for your quick response. Ok, I think I have the correct module and sub routine to call, but now I am having great difficulty installing the use Math::GSL::CDF library. I tried this on my PC with: ppm install Math-GSL (and several other tries) with no luck. Also, I tried on my Linux server using: perl -MCPAN -e shell and subsequently: cpan> install Math-GSL ... again with no luck. I have Perl version 5.8.8 on both platforms. The error on linux strangely states: Perl v5.8.8 required--this is only v5.8.5, stopped at Makefile.PL line 2. Any help? Thank you!
        This is a long shot, but have you tried installing with CPANPLUS?

        I've recently run into a case where the installation of dependencies that failed under CPAN would work under CPANPLUS (I was doing strange things, I admit). This case involved a deeply-nested dependency, though, so if your error is for the top-level module CPANPLUS might not make a difference.

        My computer crashed last week, so I'm in the process of reinstalling gsl. I should have an answer for you soon...

        Update: I couldn't replicate your error, but I had a problem with Build.PL finding 'gsl'. Evidently, the module has some problems with 7 passes and 7 fails. Check the bug reports.

Re: Hypergeometric Distribution
by BrowserUk (Patriarch) on Aug 12, 2008 at 00:25 UTC
Re: Hypergeometric Distribution
by Anonymous Monk on Aug 11, 2008 at 23:23 UTC
    Thank you so much for your quick response. Ok, I think I have the correct module and sub routine to call, but now I am having great difficulty installing the use Math::GSL::CDF library. I tried this on my PC with: ppm install Math-GSL (and several other tries) with no luck. Also, I tried on my Linux server using: perl -MCPAN -e shell and subsequently: cpan> install Math-GSL ... again with no luck. I have Perl version 5.8.8 on both platforms. The error on linux strangely states: Perl v5.8.8 required--this is only v5.8.5, stopped at Makefile.PL line 2. Any help? Thank you!
      Hi,
      If you need a Math-GSL (latest version 0.07) ppm for Win32, just save the below as 'Math-GSL.ppd':
      <?xml version="1.0" encoding="UTF-8"?> <SOFTPKG NAME="Math-GSL" VERSION="0,07,0,0"> <TITLE>Math-GSL</TITLE> <ABSTRACT></ABSTRACT> <AUTHOR></AUTHOR> <IMPLEMENTATION> <OS NAME="MSWin32" /> <ARCHITECTURE NAME="MSWin32-x86-multi-thread-5.8" /> <CODEBASE HREF="http://members.optusnet.com.au/~sisyphus1/Math-GSL +-0.07_58.tar.gz" /> <PROVIDE NAME="Math::GSL" VERSION="0.07" /> </IMPLEMENTATION> </SOFTPKG>
      Then run ppm install Math-GSL.ppd

      Note that it apparently needs perl 5.8.8 - according to the requirements as specified by the module's authors.

      In a week or so I'll see if randyk wants to put it (plus the 5.10 version) in his ppm reps. There's one minor problem with it at the moment (in that gsl_set_error_handler_off is not having the desired effect). It's easy to work around that shortcoming, but I'd like to get it sorted before I approach randyk.

      Cheers,
      Rob
        Thank you, I tried this, and got the following error: Downloading Math-GSL-0.07...not found ppm install failed: 404 Not Found Does it matter what folder I place it in? Also, I am Windows XP, will this still work? Thank you so much! Aloha, Annette
        Thank you! Thank you! Thank you! You have made me a happy cat! I did fix the line wrap last time, but silly me missed the + sign. You're a life saver! Much Mahalo as we say here! Aloha, Annette
Re: Hypergeometric Distribution
by educated_foo (Vicar) on Aug 12, 2008 at 14:35 UTC