cardUC: Cardioid Distribution

CardR Documentation

Cardioid Distribution

Description

Density, distribution function, quantile function and random generation for the cardioid distribution.

Usage

dcard(x, mu, rho, log = FALSE)
pcard(q, mu, rho, lower.tail = TRUE, log.p = FALSE)
qcard(p, mu, rho, lower.tail = TRUE, log.p = FALSE, tol0 = 1e-6)
rcard(n, mu, rho)
dcard2(x, mu, rho2 = 0, log = FALSE)
pcard2(q, mu, rho2 = 0, lower.tail = TRUE, log.p = FALSE)
qcard2(p, mu, rho2 = 0, lower.tail = TRUE, log.p = FALSE,
       tol0 = 1e-6)
rcard2(n, mu, rho2, tol0 = 1e-4)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

n

number of observations. Same as in runif.

mu, rho, rho2

See cardioid and cardioid2 for more information. Note: rho2 = 2 * rho, or equivalently, \rho_2 = 2 \rho so is in [0, 1].

tol0

Numeric, positive and small. Used under different contexts, any value within a certain tolerance is treated as being equivalent to 0. For example, if 0 <= rho2 < tol0 then the distribution is treated as uniform. Another context is for the algorithm to solve for the roots of a nonlinear system of equations.

log

Logical. If log = TRUE then the logarithm of the density is returned.

lower.tail, log.p

Same meaning as in pnorm or qnorm.

Details

See cardioid and cardioid2, the VGAM family functions for estimating the two parameters by maximum likelihood estimation, for the formula of the probability density function and other details.

Value

dcard/dcard2 give the density, pcard/pcard2 give the distribution function, qcard/qcard2 give the quantile function, and rcard/rcard2 generates random deviates.

Note

Convergence problems might occur with rcard.

Author(s)

Thomas W. Yee

References

Pewsey, A. (2025). On Jeffreys's cardioid distribution. Computational Statistics and Data Analysis, 82, in press.

See Also

cardioid, cardioid2.

Examples

## Not run: 
mu <- 4; rho2 <- 0.4 * 2; x <- seq(-0.5, 2*pi+0.5, len = 1001)
plot(x, dcard2(x, mu, rho2), type = "l", las = 1, ylim = 0:1,
     ylab = paste0("[dp]card2(mu=", mu, ", rho2=", rho2, ")"),
     main = "Blue is density, orange the CDF", col = "blue",
     sub = "Purple lines are the 10,20,...,90 percentiles")
lines(x, pcard2(x, mu, rho2), col = "orange")

probs <- seq(0, 1, by = 0.1)
Q <- qcard2(probs, mu, rho2)
lines(Q, dcard2(Q, mu, rho2), col = 3, lty = 3, type = "h")
lines(Q, pcard2(Q, mu, rho2), col = 3, lty = 3, type = "h")
abline(h = probs, v = c(0, 2*pi), col = 3, lty = 3)
max(abs(pcard2(Q, mu, rho2) - probs))  # Should be 0

## End(Not run)

VGAM documentation built on Dec. 4, 2025, 1:07 a.m.