Hi,
I was recently looking at the fOptions package and I was wondering if
anyone knows why the authors of the package bothered to write functions for
CND and NDF, when they exist as pnorm and dnorm? I realize there's the
possibility that pnorm and dnorm may not have existed when fOptions was
written. Regardless, I was wondering it there's some non-obvious advantage
to using CND or NDF versus the base stats functions. If anything, from
http://svn.r-project.org/R/trunk/src/nmath/pnorm.c it sounds like pnorm
could be slightly more accurate.
"This transportable program uses rational functions that theoretically
approximate
the normal distribution function to at least 18 significant decimal digits.
The accuracy achieved depends on the arithmetic system, the compiler, the
intrinsic functions, and proper selection of the machine-dependent
constants."
They seem to basically return the same values plus or minus some extremely
small floating point error.
library(fOptions)
> x <- seq(-4, 4, 0.01)
> all.equal(pnorm(x), CND(x))
[1] "Mean relative difference: 8.845649e-08"
> all.equal(dnorm(x), NDF(x))
[1] TRUE
Thanks,
James
[[alternative HTML version deleted]]