Learn R Programming

mistr (version 0.0.6)

r.compdist: Random Generation

Description

r is a generic function that generates random deviates of a distribution object.

Usage

# S3 method for compdist
r(O, n)

# S3 method for mixdist r(O, n)

r(O, n)

# S3 method for standist r(O, n)

# S3 method for hyperdist r(O, n)

# S3 method for wilcoxdist r(O, n)

# S3 method for trans_univdist r(O, n)

Value

Vector of computed results.

Arguments

O

distribution object.

n

number of observations.

Details

Methods of r function generates random deviates of offered distribution from the package mistr. The function makes use of the r[sufix] functions as rnorm or rbeta and thus, if a new distribution is added, these functions must be reachable through the search path.

For more complicated composite distributions, where one of the components is a mixture distribution, the function performs a rejection sampling of mixture random numbers to improve the speed.

Examples

Run this code
N <- normdist(1, 3)
r(N, 5)

C <- cauchydist()
M <- mixdist(N, C, weights = c(0.5, 0.5))
r(M, 5)

CC <- compdist(N, C, weights = c(0.5, 0.5), breakpoints = 1)
CCC <- 2*C+5
r(CCC, 5)

Run the code above in your browser using DataLab