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

Discrete

Discrete Distribution


Description

These functions provide information about the discrete distribution where the probability of the elements of values is proportional to the values given in probs, which are normalized to sum up to 1. ddiscrete gives the density, pdiscrete gives the distribution function, qdiscrete gives the quantile function and rdiscrete generates random deviates.

Usage

ddiscrete(x, probs, values = 1:length(probs))
pdiscrete(q, probs, values = 1:length(probs))
qdiscrete(p, probs, values = 1:length(probs))
rdiscrete(n, probs, values = 1:length(probs), ...)

Arguments

x,q

vector or array of quantiles.

p

vector or array of probabilities.

n

number of observations.

probs

probabilities of the distribution.

values

values of the distribution.

...

ignored (only there for backwards compatibility)

Details

The random number generator is simply a wrapper for sample and provided for backwards compatibility only.

Author(s)

Andreas Weingessel and Friedrich Leisch

Examples

## a vector of length 30 whose elements are 1 with probability 0.2
## and 2 with probability 0.8.
rdiscrete (30, c(0.2, 0.8))

## a vector of length 100 whose elements are A, B, C, D.
## The probabilities of the four values have the relation 1:2:3:3
rdiscrete (100, c(1,2,3,3), c("A","B","C","D"))

e1071

Misc Functions of the Department of Statistics, Probability Theory Group (Formerly: E1071), TU Wien

v1.7-11
GPL-2 | GPL-3
Authors
David Meyer [aut, cre], Evgenia Dimitriadou [aut, cph], Kurt Hornik [aut], Andreas Weingessel [aut], Friedrich Leisch [aut], Chih-Chung Chang [ctb, cph] (libsvm C++-code), Chih-Chen Lin [ctb, cph] (libsvm C++-code)
Initial release

We don't support your browser anymore

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