distribution {exams.forge} | R Documentation |
Class Distribution
Description
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 withname
and parametersquantile
computes the quantiles of a distribution usingpaste0('q', name)
cdf
computes the cumulative distribution function of a distribution usingpaste0('p', name)
pmdf
computes the probability mass/density function of a distribution usingpaste0('d', name)
prob
computes the probability for a interval betweenmin
andmax
(max
included,min
excluded)prob1
computes the point probability fis.distribution
checks ifobject
is distribution object. Ifname
is given then it checks whether the distribution type is the sametoLatex
generates a LaTeX representation of the distribution an its parameter
Usage
distribution(name, ...)
## Default S3 method:
distribution(name, ..., discrete = NA)
## S3 method for class 'distribution'
quantile(x, probs = seq(0, 1, 0.25), ...)
cdf(x, q, ...)
## S3 method for class 'distribution'
print(x, ...)
## S3 method for class 'distribution'
summary(object, ...)
pmdf(d, x, ...)
## S3 method for class '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)
Arguments
name |
character: a replacement of the name of the distribution type |
... |
further named distribution parameters |
discrete |
logical: is the distribution discrete? (default: |
x |
vector of values |
probs |
numeric: vector of probabilities with values in |
q |
numeric: vector of quantiles |
object |
distribution object |
d |
distribution |
param |
character: names for the distribution parameters |
digits |
integer: number of digits used in |
min |
numeric: left border of interval |
max |
numeric: right border of interval |
tol |
numeric: tolerance for |
Value
A distribution object.
Examples
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)