Skip to contents

A collection of S4 classes that provide a flexible and structured way to work with probability distributions.

Usage

# S4 method for class 'Distribution,missing'
d(distr, x, ...)

# S4 method for class 'Distribution,missing'
p(distr, x, ...)

# S4 method for class 'Distribution,missing'
qn(distr, x, ...)

# S4 method for class 'Distribution,missing'
r(distr, n, ...)

# S4 method for class 'Distribution,missing'
ll(distr, x, ...)

# S4 method for class 'Distribution,missing'
mle(distr, x, ...)

# S4 method for class 'Distribution,missing'
me(distr, x, ...)

# S4 method for class 'Distribution,missing'
same(distr, x, ...)

Arguments

distr

a Distribution object.

x, n

missing. Agruments not supplied.

...

extra arguments.

Value

When supplied with one argument, the d(), p(), q(), r() ll() functions return the density, cumulative probability, quantile, random sample generator, and log-likelihood functions, respectively.

Details

When x or n are missing, the methods return a function that takes as input the missing argument, allowing the user to work with the function object itself. See examples.

Examples

# -----------------------------------------------------
# Beta Distribution Example
# -----------------------------------------------------

# Create the distribution
D <- Beta(3, 5)
x <- c(0.3, 0.8, 0.5)
n <- 5

# Density function
df <- d(D) ; df(x) # df is a function itself
#> [1] 2.268945 0.107520 1.640625
d(D, x) # alternative way to use the function
#> [1] 2.268945 0.107520 1.640625

# Distribution function
pf <- p(D) ; pf(x)
#> [1] 0.3529305 0.9953280 0.7734375
p(D, x)
#> [1] 0.3529305 0.9953280 0.7734375

# Inverse distribution function
qf <- qn(D) ; qf(x)
#> [1] 0.2763397 0.5167578 0.3641161
qn(D, x)
#> [1] 0.2763397 0.5167578 0.3641161

# Random Generator function
rf <- r(D) ; rf(n)
#> [1] 0.27315023 0.50569543 0.11579971 0.48033934 0.09075043
r(D, n)
#> [1] 0.2786339 0.3647822 0.4869432 0.2139102 0.4708356