dpnorm | R Documentation |
Evaluates the difference between two N(0,1)
cumulative distribution functions avoiding cancellation error.
dpnorm(x0,x1)
x0 |
vector of lower values at which to evaluate standard normal distribution function. |
x1 |
vector of upper values at which to evaluate standard normal distribution function. |
Equivalent to pnorm(x1)-pnorm(x0)
, but stable when x0
and x1
values are very close, or in the upper tail of the standard normal.
Simon N. Wood simon.wood@r-project.org
require(mgcv)
x <- seq(-10,10,length=10000)
eps <- 1e-10
y0 <- pnorm(x+eps)-pnorm(x) ## cancellation prone
y1 <- dpnorm(x,x+eps) ## stable
## illustrate stable computation in black, and
## cancellation prone in red...
par(mfrow=c(1,2),mar=c(4,4,1,1))
plot(log(y1),log(y0),type="l")
lines(log(y1[x>0]),log(y0[x>0]),col=2)
plot(x,log(y1),type="l")
lines(x,log(y0),col=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.