dens: Density, Distribution, Random Number Generation and Quantiles...

densR Documentation

Density, Distribution, Random Number Generation and Quantiles of Kernel Density Estimates

Description

Calculate the density (ddens()), the distribution (pdens()), the quantiles (qdens()) and generate random samples (rdens()) of a kernel density estimate as returned by fit_angle() or fit_steplength().

Usage

rdens(n, density)

ddens(x, density)

pdens(x, density)

qdens(p, density)

Arguments

n

integer value, the number of random samples to be generated with rdens().

density

a 'density' object (for linear kernel density estimates) or a 'density.circular' object (for circular kernel density estimates) containing information about the kernel density estimate. These objects can be obtained using fit_angle(..., parametric = FALSE) or fit_steplength(..., parametric = FALSE).

x

numeric vector giving the points where the density or distribution function is evaluated.

p

numeric vector giving the probabilities where the quantile function is evaluated.

Value

ddens() and pdens() give a vector of length length(x) containing the density or distribution function at the corresponding values of x. qdens() gives a vector of length length(p) containing the quantiles at the corresponding values of p. The function rdens() generates a vector of length n containing the random samples.

See Also

fit_angle(), fit_steplength(), fit_steplength().

Examples

set.seed(123)

steps <- rweibull(10, shape=3)
dens <- fit_steplength(x = steps, parametric = FALSE)
ddens(c(0.1,0.3), dens)
pdens(c(0.1,0.3), dens)
qdens(c(0.1,0.3), dens)
rdens(4, dens)

angles <- full2half_circ(
  circular::rvonmises(10, mu = circular::circular(0), kappa = 2)
)
dens <- fit_angle(theta = angles, parametric = FALSE)
ddens(c(0.1,0.3), dens)
pdens(c(0.1,0.3), dens)
qdens(c(0.1,0.3), dens)
rdens(4, dens)


cylcop documentation built on Oct. 30, 2022, 1:05 a.m.