Unif {joker}R Documentation

Uniform Distribution

Description

The Uniform distribution is an absolute continuous probability distribution where all intervals of the same length within the distribution's support are equally probable. It is defined by two parameters: the lower bound a and the upper bound b, with a < b.

Usage

Unif(min = 0, max = 1)

## S4 method for signature 'Unif,numeric'
d(distr, x, log = FALSE)

## S4 method for signature 'Unif,numeric'
p(distr, q, lower.tail = TRUE, log.p = FALSE)

## S4 method for signature 'Unif,numeric'
qn(distr, p, lower.tail = TRUE, log.p = FALSE)

## S4 method for signature 'Unif,numeric'
r(distr, n)

## S4 method for signature 'Unif'
mean(x)

## S4 method for signature 'Unif'
median(x)

## S4 method for signature 'Unif'
mode(x)

## S4 method for signature 'Unif'
var(x)

## S4 method for signature 'Unif'
sd(x)

## S4 method for signature 'Unif'
skew(x)

## S4 method for signature 'Unif'
kurt(x)

## S4 method for signature 'Unif'
entro(x)

llunif(x, min, max)

## S4 method for signature 'Unif,numeric'
ll(distr, x)

eunif(x, type = "mle", ...)

## S4 method for signature 'Unif,numeric'
mle(distr, x, na.rm = FALSE)

## S4 method for signature 'Unif,numeric'
me(distr, x, na.rm = FALSE)

Arguments

min, max

numeric. The distribution parameters.

distr

an object of class Unif.

x

For the density function, x is a numeric vector of quantiles. For the moments functions, x is an object of class Unif. For the log-likelihood and the estimation functions, x is the sample of observations.

log, log.p

logical. Should the logarithm of the probability be returned?

q

numeric. Vector of quantiles.

lower.tail

logical. If TRUE (default), probabilities are P(X \leq x), otherwise P(X > x).

p

numeric. Vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

type

character, case ignored. The estimator type (mle or me).

...

extra arguments.

na.rm

logical. Should the NA values be removed?

Details

The probability density function (PDF) of the Uniform distribution is:

f(x; a, b) = \frac{1}{b - a}, \quad a \le x \le b .

Value

Each type of function returns a different type of object:

See Also

Functions from the stats package: dunif(), punif(), qunif(), runif()

Examples

# -----------------------------------------------------
# Uniform Distribution Example
# -----------------------------------------------------

# Create the distribution
a <- 3 ; b <- 5
D <- Unif(a, b)

# ------------------
# dpqr Functions
# ------------------

d(D, c(0.3, 0.8, 0.5)) # density function
p(D, c(0.3, 0.8, 0.5)) # distribution function
qn(D, c(0.4, 0.8)) # inverse distribution function
x <- r(D, 100) # random generator function

# alternative way to use the function
df <- d(D) ; df(x) # df is a function itself

# ------------------
# Moments
# ------------------

mean(D) # Expectation
var(D) # Variance
sd(D) # Standard Deviation
skew(D) # Skewness
kurt(D) # Excess Kurtosis
entro(D) # Entropy

# List of all available moments
mom <- moments(D)
mom$mean # expectation

# ------------------
# Point Estimation
# ------------------

ll(D, x)
llunif(x, a, b)

eunif(x, type = "mle")
eunif(x, type = "me")

mle(D, x)
me(D, x)
e(D, x, type = "mle")

mle("unif", x) # the distr argument can be a character

[Package joker version 0.14.2 Index]