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

Aloha! I am trying to use qnorm() from Math::CDF. It works generally, but how can I get a distribution using a mean and standard deviation? For eaxmple, I am trying get tercile cut-offs (33% and 67%) so I want say the qnorm of 33% and 67% with a mean of 44 and standard deviation of 2.5. It seems like the perl qnorm does not have this option?? Thanks! Annette

Replies are listed 'Best First'.
Re: qnorm question
by talexb (Chancellor) on Mar 21, 2007 at 16:50 UTC

    It seems this is more a question for DCDFLIB than it is a Perl question.

    However, if you want to manipulate the mean and variance, isn't that just a matter of arithmetic? You just normalize your incoming data based on a mean and a variance down to a standard distribution where the mean is 0 and the variance is 1, and go from there.

    Not that I remember that much -- my last Stats class was over 20 years ago. ;)

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

    ps: You can link to a CPAN module using [cpan://{CPAN module name here}] like this: Math::CDF.

Re: qnorm question
by almut (Canon) on Mar 21, 2007 at 17:30 UTC

    The underlying DCDFLIB routine cdfnor() actually does take mean and stddev parameters, but the XS code (Perl binding) which calls the DCDFLIB routine uses hardcoded values for mean and stddev (0.0 and 1.0). This is no big problem, however, as you can easily scale/displace the return value yourself. Just multiply by the stddev, and add the mean, e.g.

    use Math::CDF qw(qnorm); for my $p (0.33, 0.67) { print qnorm($p) * 2.5 + 44, "\n"; }

    which gives

    42.9002170858169 45.0997829141831
      Thank you! Thank you! Works great!