Cardioid Distribution
cardUC.RdDensity, 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
cardioidandcardioid2for 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 < tol0then 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 = TRUEthen the logarithm of the density is returned.- lower.tail, log.p
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.
References
Pewsey, A. (2025). On Jeffreys's cardioid distribution. Computational Statistics and Data Analysis, 82, in press.
Examples
if (FALSE) { # \dontrun{
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
} # }