xDensity: Implementation of 'd/p/q/r' functions for 'xDensity'...

Description Usage Arguments Details Value See Also Examples

Description

Implementation of d/p/q/r functions for xDensity distributions.

Usage

1
2
3
4
5
6
7
dXD(x, xDens, log = FALSE)

pXD(q, xDens, lower.tail = TRUE, log.p = FALSE)

qXD(p, xDens, lower.tail = TRUE, log.p = FALSE)

rXD(n, xDens)

Arguments

x, q

Vector of quantiles.

xDens

Object of class xDensity representing the distribution.

log, log.p

Logical; if TRUE, probabilities p are given as log(p).

lower.tail

Logical; if TRUE (default), probabilities are P[X <= x] otherwise, P[X > x].

p

Vector of probabilities.

n

Number of observations.

Details

Extended density (or xDensity) objects provide a compact representation of arbitrary one-dimensional distributions defined on the real line. That is, an xDensity object is a list with the following elements:

Value

For the underlying xDensity object, dXD gives the density, pXD gives the distribution function, qXD gives the quantile function and rXD generates n random values.

See Also

matrixXD, kernelXD, gc4XD for various xDensity object constructors.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# xDensity representation of a N(0,1) distribution

# construct the xDensity object using the known PDF dnorm
xseq <- seq(-4, 4, len = 500) # where to evaluate density
xDens <- matrixXD(cbind(xseq, dnorm(xseq)))

# check random sampling
x <- rXD(1e5, xDens = xDens)
hist(x, breaks = 100, freq = FALSE)
curve(dnorm, add = TRUE, col = "red")

# check PDF
x <- rnorm(5)
rbind(true = dnorm(x, log = TRUE), xDens = dXD(x, xDens, log = TRUE))

# check CDF
rbind(true = pnorm(x, log = TRUE), xDens = pXD(x, xDens, log = TRUE))

# check inverse-CDF
probs <- runif(5)
rbind(true = qnorm(probs), xDens = qXD(probs, xDens))

mlysy/GaussCop documentation built on Nov. 6, 2019, 6:19 p.m.