distrFunc: distrFunc

Description Usage Arguments Details Value Examples

View source: R/distrFunc.R

Description

Creates a distrFunc object from a distribution name. The density/mass (func='d'), the cumulative distribution (func='p') and the quantile distribution (func='q') function are possible choices.

Usage

1
2
3
4
5
6
distrFunc(type, ...)

## Default S3 method:
distrFunc(type, func = "d", discrete = F, supp = c(NA,
  NA), xlim = c(NA, NA), ylim = c(NA, NA), tol = .Machine$double.eps^0.25,
  pretty = T, ...)

Arguments

type

character: distribution name

...

further parameters depending on the distribution

func

character: type of function (default: 'd')

discrete

logical: if distribution is discrete or not (default: FALSE)

supp

range: the support of the distribution function (default: c(NA, NA), detect automatically)

xlim

range: set the range of the non-zero density/mass function (default: c(NA, NA), detect automatically)

ylim

range: set the range of the y-values (default: c(NA, NA), detect automatically)

tol

numeric: tolerance value (default: .Machine$double.eps^0.25)

pretty

logical: use the function pretty to determine good limits

Details

The standard distributions from the stats package (except the multinomial distribution) are supported

beta beta distribution
binom binomial (including Bernoulli) distribution
cauchy Cauchy distribution
exp exponential distribution
f F distribution
gamma gamma distribution
geom geometric distribution
hyper hypergeometric distribution
lnorm log-normal distribution
nbinom negative binomial distribution
norm normal distribution
pois Poisson distribution
t Student's t distribution
unif uniform distribution
weibull Weibull distribution

The function computes the range of the non-zero density/mass function and the maximum of the density/mass function.

For a standard distribution of the stats package you need only to provide the name in the parameter type. For a non-standard distribution with the name 'wwww' is expected that the following functions exist:

dwwww(x, ...) density/mass function
pwwww(q, ...) distribution function
qwwww(p, ...) quantile function

A discrete distribution must be defined for non-negative integers.

The range of non-zero density/mass function is computed by qwwww(0, ...) and qwwww(1, ...). If any of these quantiles returns plus/minus infinity then qwwww(tol, ...) or qwwww(1-tol, ...) is used. Alternatively you may set the range by the parameter xlim and a NA value implies the quantile function should be used.

Value

a distribution object

Examples

1
2
d <- distrFunc("norm")
d

sigbertklinke/mmstat documentation built on May 14, 2019, 8:36 a.m.