Learn R Programming

extraDistr (version 1.8.1)

DiscreteNormal: Discrete normal distribution

Description

Probability mass function, distribution function and random generation for discrete normal distribution.

Usage

ddnorm(x, mean = 0, sd = 1, log = FALSE)
pdnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
qdnorm(p, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
rdnorm(n, mean = 0, sd = 1)

Arguments

x, q
vector of quantiles.
mean
vector of means.
sd
vector of standard deviations.
log, log.p
logical; if TRUE, probabilities p are given as log(p).
lower.tail
logical; if TRUE (default), probabilities are $P[X \le x]$ otherwise, $P[X > x]$.
p
vector of probabilities.
n
number of observations. If length(n) > 1, the length is taken to be the number required.

Details

Probability mass function

$$ f(x) = \Phi\left(\frac{x-\mu+1}{\sigma}\right) - \Phi\left(\frac{x-\mu}{\sigma}\right) $$

References

Roy, D. (2003). The discrete normal distribution. Communications in Statistics-Theory and Methods, 32, 1871-1883.

See Also

Normal

Examples

Run this code

x <- rdnorm(1e5, 7, 35)
xx <- -150:150
hist(x, 100, freq = FALSE)
lines(xx-0.5, ddnorm(xx, 7, 35), col = "red")
hist(pdnorm(x, 7, 35))
plot(ecdf(x))
lines(xx, pdnorm(xx, 7, 35), col = "red", lwd = 2)

Run the code above in your browser using DataLab