tags:

views:

107

answers:

1

Seems like in Perl this should be easy or a module, but I have not found an easy answer yet. I have a calculated z normal score and the mean, but have not found an easy method to calculate the percentage. The solutions I have found are for looking it up using a statistics table, but it seems like something that common would have a module or something easy. (ie a z-score of -3 is -3 sigma and has a percentage of 0.1%). I don't want to have to build a table in perl and then interpolate if I don't need to. Anyone know?

+9  A: 

I'm not 100% sure since the only description you gave is "the percentage", but I think the function you need is the cumulative probability function for the normal function. You can get this from the module Math::CDF.

use Math::CDF;
my $prob = Math::CDF::pnorm(-3);
printf "%.1f%%\n", $prob * 100; # Prints 0.1%
hobbs