Laplace {joker}R Documentation

Laplace Distribution

Description

The Laplace distribution, also known as the double exponential distribution, is a continuous probability distribution that is often used to model data with sharp peaks and heavy tails. It is parameterized by a location parameter \mu and a scale parameter b > 0.

Usage

Laplace(mu = 0, sigma = 1)

dlaplace(x, mu, sigma, log = FALSE)

plaplace(q, mu, sigma, lower.tail = TRUE, log.p = FALSE)

qlaplace(p, mu, sigma, lower.tail = TRUE, log.p = FALSE)

rlaplace(n, mu, sigma)

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

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

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

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

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

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

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

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

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

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

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

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

## S4 method for signature 'Laplace'
finf(x)

lllaplace(x, mu, sigma)

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

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

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

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

vlaplace(mu, sigma, type = "mle")

## S4 method for signature 'Laplace'
avar_mle(distr)

## S4 method for signature 'Laplace'
avar_me(distr)

Arguments

mu, sigma

numeric. The distribution parameters.

x

For the density function, x is a numeric vector of quantiles. For the moments functions, x is an object of class Laplace. 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.

distr

an object of class Laplace.

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 Laplace distribution is:

f(x; \mu, b) = \frac{1}{2b} \exp\left(-\frac{|x - \mu|}{b}\right) .

Value

Each type of function returns a different type of object:

Examples

# -----------------------------------------------------
# Laplace Distribution Example
# -----------------------------------------------------

# Create the distribution
m <- 3 ; s <- 5
D <- Laplace(m, s)

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

d(D, c(0.3, 2, 10)) # density function
p(D, c(0.3, 2, 10)) # 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
median(D) # Median
mode(D) # Mode
var(D) # Variance
sd(D) # Standard Deviation
skew(D) # Skewness
kurt(D) # Excess Kurtosis
entro(D) # Entropy
finf(D) # Fisher Information Matrix

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

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

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

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

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

# ------------------
# Estimator Variance
# ------------------

vlaplace(m, s, type = "mle")
vlaplace(m, s, type = "me")

avar_mle(D)
avar_me(D)

v(D, type = "mle")

[Package joker version 0.14.2 Index]