Holds an univariate distribution including its parameters. The name of the distribution is used to determine the right use of the function.
For example, in the case of function for quantiles: paste0("q", name). Usually the full name has to be used; some abbreviated names are possible:
binom binomial distribution, parameters: size, prob
hyper hypergeometric distribution, parameters: m, n, k
geom geometric distribution, parameters: prob
pois Poisson distribution, parameters: lambda
unif continuous uniform distribution, parameters: min, max
dunif discrete uniform distribution, parameters: min, max
dunif2 continuous uniform distribution, parameters: min, max
exp exponential distribution, parameter: rate
norm normal distribution, parameters: mean, sd
lnorm log-normal distribution, parameters: meanlog, sdlog
t Student t distribution, parameter: df
chisq chi-squared distribution, parameter: df
f F distribution, parameters: df1, df2
Note that a probability mass/density, quantile and a cumulative distribution function must exist.
The following functions exists for disributions:
distribution creates a distribution with name and parameters
quantile computes the quantiles of a distribution using paste0('q', name)
cdf computes the cumulative distribution function of a distribution using paste0('p', name)
pmdf computes the probability mass/density function of a distribution using paste0('d', name)
prob computes the probability for a interval between min and max (max included, min excluded)
prob1 computes the point probability f
is.distribution checks if object is distribution object. If name is given then it checks whether the distribution type is the same
toLatex generates a LaTeX representation of the distribution an its parameter
distribution(name, ...)# S3 method for default
distribution(name, ..., discrete = NA)
# S3 method for distribution
quantile(x, probs = seq(0, 1, 0.25), ...)
cdf(x, q, ...)
# S3 method for distribution
print(x, ...)
# S3 method for distribution
summary(object, ...)
pmdf(d, x, ...)
# S3 method for distribution
toLatex(object, name = NULL, param = NULL, digits = 4, ...)
is.distribution(object, name = NULL)
prob(d, min = -Inf, max = +Inf, tol = 1e-06)
prob1(d, x, tol = 1e-06)
compute_cdf(x, q, ...)
compute_pmdf(d, x, ...)
compute_probability(d, min = -Inf, max = +Inf, tol = 1e-06)
point_probability(d, x, tol = 1e-06)
pprob(d, x, tol = 1e-06)
is_distribution(object, name = NULL)
A distribution object.
character: a replacement of the name of the distribution type
further named distribution parameters
logical: is the distribution discrete? (default: NA)
vector of values
numeric: vector of probabilities with values in \([0,1]\).
numeric: vector of quantiles
distribution object
distribution
character: names for the distribution parameters
integer: number of digits used in signif
numeric: left border of interval
numeric: right border of interval
numeric: tolerance for max==min (default: 1e-6)
d <- distribution("norm", mean=0, sd=1)
quantile(d)
quantile(d, c(0.025, 0.975))
cdf(d, 0)
is.distribution(d)
is.distribution(d, "t")
toLatex(d)
Run the code above in your browser using DataLab