Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

DiscreteUniform

Discrete uniform distribution


Description

Probability mass function, distribution function, quantile function and random generation for the discrete uniform distribution.

Usage

ddunif(x, min, max, log = FALSE)

pdunif(q, min, max, lower.tail = TRUE, log.p = FALSE)

qdunif(p, min, max, lower.tail = TRUE, log.p = FALSE)

rdunif(n, min, max)

Arguments

x, q

vector of quantiles.

min, max

lower and upper limits of the distribution. Must be finite.

log, log.p

logical; if TRUE, probabilities p are given as log(p).

lower.tail

logical; if TRUE (default), probabilities are P[X ≤ 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

If min == max, then discrete uniform distribution is a degenerate distribution.

Examples

x <- rdunif(1e5, 1, 10) 
xx <- -1:11
plot(prop.table(table(x)), type = "h")
lines(xx, ddunif(xx, 1, 10), col = "red")
hist(pdunif(x, 1, 10))
xx <- seq(-1, 11, by = 0.01)
plot(ecdf(x))
lines(xx, pdunif(xx, 1, 10), col = "red")

extraDistr

Additional Univariate and Multivariate Distributions

v1.9.1
GPL-2
Authors
Tymoteusz Wolodzko
Initial release
2020-08-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.