I think there is some confusion about terminology here:
PDL::GSL::RNG can give random deviates from the standard normal
distribution (and a whole bunch others) and does this quite well.
This is what I would have understood from Steve's question, however
the example says pnorm(0) = 0.5 which uses the notation in R for the
CDF. To calculate this you need to do an integral yourself AFAIK.
If you want a general function ala R, you can do something like:
sub pnorm {
my ($x, $sigma, $mu) = @_;
$sigma= 1 unless defined($sigma);
$mu = 0 unless defined($mu);
return 0.5*(1+erf(($x-$mu)/(sqrt(2)*$sigma)));
}
(very similar to Pete Ratzlaff's statement earlier). The inverse of
this is more fiddly - the only Perl implementation I know of (probably
there are more!) is this one: http://home.online.no/~pjacklam/notes/invnorm/
(which you also find linked from one of the Wikipedia articles about
the normal distribution or quantile functions, I forget which). This
is what R calls qnorm.
Cheers,
Jarle.
On 29 Sep 2008, at 21:42, Craig DeForest wrote:
> I think PDL::GSL::RNG can do it.
>
>
> On Sep 29, 2008, at 1:22 PM, Derek Lamb wrote:
>
>> Steve Cicala wrote:
>>> Can anyone point me to the function in PDL that returns values from
>>> the standard normal distribution?
>>>
>>> i.e.
>>> 0.5=pnorm(0)
>>>
>>> Thanks,
>>>
>>> Steve
>> As far as I know there is no such thing. There is/was a module
>> PDL::Gaussian that purported to do this, among other things. But it
>> was
>> very broken, never used, never asked about, and is in the process of
>> being pulled from the PDL distribution.
>>
>> Shouldn't be too hard to cook one up yourself using
>> PDL::Func::integrate. Or maybe even PDL::Func::interpolate and
>> PDL::Ufunc::(d)cumusumover , if you only want to compute it once.
>>
>> cheers,
>> Derek
>>
>> _______________________________________________
>> Perldl mailing list
>> [email protected]
>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>>
>
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl