Discrete distribution

DESCRIPTION:

Density, cumulative probability, quantiles, and random generation for a discrete distribution

USAGE:

ddiscrete(x, prob = NULL, values = seq(along = prob),
             log = FALSE)
pdiscrete(q, prob = NULL, values = seq(along = prob),
             lower.tail = TRUE, log.p = FALSE)
qdiscrete(p, prob = NULL, values = seq(along = prob),
             lower.tail = TRUE, log.p = FALSE)
rdiscrete(n, prob = NULL, values = seq(along = prob)) 

REQUIRED ARGUMENTS:

x
vector of quantiles. Missing values ( NAs) are allowed.
q
vector of quantiles. numerical, values at which to compute the distribution function. Missing values ( NAs) are allowed.
p
vector of probabilities. Missing values ( NAs) are allowed.
n
sample size.

OPTIONAL ARGUMENTS:

prob
a vector the same length as values, containing probabilities to define a distribution with unequal probabilities. These are normalized to sum to 1. NULL indicates equal probabilities.
values
vector determining where the discrete distribution has non-zero probability.
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].

VALUE:

density ( ddiscrete), probability ( pdiscrete), quantile ( qdiscrete) or random sample ( rdiscrete) for a discrete distribution with probability given by prob with support at values. prob.

DETAILS:

Elements of x, q or p that are missing cause the corresponding elements of the result to be missing.

The quantile is defined as the smallest value q such that Pr(random variate <= q) >= p. Other definitions are more appropriate if values is a set of random data; see .

SEE ALSO:

is similar to pdiscrete, but gives counts rather than proportions of the number of values that are <= each of the quantiles. , , .

EXAMPLES:

x <- c(1,3,5) 
z <- 0:6 
pdiscrete(z, values = x) 
countLessThan(x, z) 
pdiscrete(z, values = x, prob=c(.5,.2,.1)) # are normalized
rdiscrete(5, values = x)