2ParExponential: The 2-Parameter Exponential Distribution

Description Usage Arguments Details Value See Also Examples

Description

Density, distribution function, quantile function, and random generation for the 2-parameter exponential distribution with rate equal to rate and shift equal to shift.

Usage

1
2
3
4
d2exp(x, rate = 1, shift = 0, log = FALSE)
p2exp(q, rate = 1, shift = 0, lower.tail = TRUE, log.p = FALSE)
q2exp(p, rate = 1, shift = 0, lower.tail = TRUE, log.p = FALSE)
r2exp(n, rate = 1, shift = 0)

Arguments

x,q

Vector of quantiles.

p

Vector of probabilities.

n

The number of observations. If length>1, then the length is taken to be the number required.

rate

Vector of rates.

shift

Vector of shifts.

log,log.p

Logical vectors. If TRUE, then probabilities are given as log(p).

lower.tail

Logical vector. If TRUE, then probabilities are P[X≤ x], else P[X>x].

Details

If rate or shift are not specified, then they assume the default values of 1 and 0, respectively.

The 2-parameter exponential distribution has density

f(x) = exp(-(x-μ)/β)/β,

where x≥μ, μ is the shift parameter, and β>0 is the scale parameter.

Value

d2exp gives the density, p2exp gives the distribution function, q2exp gives the quantile function, and r2exp generates random deviates.

See Also

runif and .Random.seed about random number generation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Randomly generated data from the 2-parameter exponential 
## distribution.

set.seed(100)
x <- r2exp(n = 500, rate = 3, shift = -10)
hist(x, main = "Randomly Generated Data", prob = TRUE)

x.1 = sort(x)
y <- d2exp(x = x.1, rate = 3, shift = -10)
lines(x.1, y, col = 2, lwd = 2)

plot(x.1, p2exp(q = x.1, rate = 3, shift = -10), type = "l", 
     xlab = "x", ylab = "Cumulative Probabilities")

q2exp(p = 0.20, rate = 3, shift = -10, lower.tail = FALSE)
q2exp(p = 0.80, rate = 3, shift = -10)

Example output

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 
[1] -5.171686
[1] -5.171686

tolerance documentation built on Feb. 6, 2020, 5:08 p.m.