DiscreteNormal function

Discrete normal distribution

Discrete normal distribution

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

ddnorm(x, mean = 0, sd = 1, log = FALSE) pdnorm(q, 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[Xx]P[X \le x]

    otherwise, P[X>x]P[X > x].

  • n: number of observations. If length(n) > 1, the length is taken to be the number required.

Details

Probability mass function

f(x)=Φ(xμ+1σ)Φ(xμσ)f(x)=Φ((xμ+1)/σ)Φ((xμ)/σ) f(x) = \Phi\left(\frac{x-\mu+1}{\sigma}\right) - \Phi\left(\frac{x-\mu}{\sigma}\right)f(x) = \Phi((x-\mu+1)/\sigma) - \Phi((x-\mu)/\sigma)

Cumulative distribution function

F(x)=Φ(x+1μσ)F(x)=Φ((floor(x)+1μ)/σ) F(x) = \Phi\left(\frac{\lfloor x \rfloor + 1 - \mu}{\sigma}\right)F(x) = \Phi((floor(x)+1-\mu)/\sigma)

Examples

x <- rdnorm(1e5, 0, 3) xx <- -15:15 plot(prop.table(table(x))) lines(xx, ddnorm(xx, 0, 3), col = "red") hist(pdnorm(x, 0, 3)) plot(ecdf(x)) xx <- seq(-15, 15, 0.1) lines(xx, pdnorm(xx, 0, 3), col = "red", lwd = 2, type = "s")

References

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

See Also

Normal

  • Maintainer: Tymoteusz Wolodzko
  • License: GPL-2
  • Last published: 2023-11-30