Title: | Multivariate Cauchy Distribution; Kullback-Leibler Divergence |
---|---|
Description: | Distance between multivariate Cauchy distributions, as presented by N. Bouhlel and D. Rousseau (2022) <doi:10.3390/e24060838>. Manipulation of multivariate Cauchy distributions. |
Authors: | Pierre Santagostini [aut, cre], Nizar Bouhlel [aut] |
Maintainer: | Pierre Santagostini <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.3.3 |
Built: | 2024-12-23 13:40:02 UTC |
Source: | CRAN |
This package provides tools for multivariate Cauchy distributions (MCD):
Calculation of distances/divergences between MCD:
Kullback-Leibler divergence: kldcauchy
Tools for MCD:
Probability density: dmcd
Simulation from a MCD: rmcd
Plot of the density of a MCD with 2 variables: plotmcd
, contourmcd
Pierre Santagostini [email protected], Nizar Bouhlel [email protected]
N. Bouhlel, D. Rousseau, A Generic Formula and Some Special Cases for the Kullback–Leibler Divergence between Central Multivariate Cauchy Distributions. Entropy, 24, 838, July 2022. doi:10.3390/e24060838 #' @keywords internal
Useful links:
Report bugs at https://forgemia.inra.fr/imhorphen/mcauchyd/-/issues
Draws the contour plot of the probability density of the multivariate Cauchy distribution with 2 variables
with location parameter mu
and scatter matrix Sigma
.
contourmcd(mu, Sigma, xlim = c(mu[1] + c(-10, 10)*Sigma[1, 1]), ylim = c(mu[2] + c(-10, 10)*Sigma[2, 2]), zlim = NULL, npt = 30, nx = npt, ny = npt, main = "Multivariate Cauchy density", sub = NULL, nlevels = 10, levels = pretty(zlim, nlevels), tol = 1e-6, ...)
contourmcd(mu, Sigma, xlim = c(mu[1] + c(-10, 10)*Sigma[1, 1]), ylim = c(mu[2] + c(-10, 10)*Sigma[2, 2]), zlim = NULL, npt = 30, nx = npt, ny = npt, main = "Multivariate Cauchy density", sub = NULL, nlevels = 10, levels = pretty(zlim, nlevels), tol = 1e-6, ...)
mu |
length 2 numeric vector. |
Sigma |
symmetric, positive-definite square matrix of order 2. The scatter matrix. |
xlim , ylim
|
x-and y- limits. |
zlim |
z- limits. If NULL, it is the range of the values of the density on the x and y values within |
npt |
number of points for the discretisation. |
nx , ny
|
number of points for the discretisation among the x- and y- axes. |
main , sub
|
main and sub title, as for |
nlevels , levels
|
arguments to be passed to the |
tol |
tolerance (relative to largest variance) for numerical lack of positive-definiteness in Sigma, for the estimation of the density. see |
... |
additional arguments to |
Returns invisibly the probability density function.
Pierre Santagostini, Nizar Bouhlel
N. Bouhlel, D. Rousseau, A Generic Formula and Some Special Cases for the Kullback–Leibler Divergence between Central Multivariate Cauchy Distributions. Entropy, 24, 838, July 2022. doi:10.3390/e24060838
dmcd
: probability density of a multivariate Cauchy density
plotmcd
: 3D plot of a bivariate Cauchy density.
mu <- c(1, 4) Sigma <- matrix(c(0.8, 0.2, 0.2, 0.2), nrow = 2) contourmcd(mu, Sigma)
mu <- c(1, 4) Sigma <- matrix(c(0.8, 0.2, 0.2, 0.2), nrow = 2) contourmcd(mu, Sigma)
Density of the multivariate ( variables) Cauchy distribution (MCD)
with location parameter
mu
and scatter matrix Sigma
.
dmcd(x, mu, Sigma, tol = 1e-6)
dmcd(x, mu, Sigma, tol = 1e-6)
x |
length |
mu |
length |
Sigma |
symmetric, positive-definite square matrix of order |
tol |
tolerance (relative to largest eigenvalue) for numerical lack of positive-definiteness in Sigma. |
The density function of a multivariate Cauchy distribution is given by:
The value of the density.
Pierre Santagostini, Nizar Bouhlel
rmcd
: random generation from a MCD.
plotmcd
, contourmcd
: plot of a bivariate Cauchy density.
mu <- c(0, 1, 4) sigma <- matrix(c(1, 0.6, 0.2, 0.6, 1, 0.3, 0.2, 0.3, 1), nrow = 3) dmcd(c(0, 1, 4), mu, sigma) dmcd(c(1, 2, 3), mu, sigma)
mu <- c(0, 1, 4) sigma <- matrix(c(1, 0.6, 0.2, 0.6, 1, 0.3, 0.2, 0.3, 1), nrow = 3) dmcd(c(0, 1, 4), mu, sigma) dmcd(c(1, 2, 3), mu, sigma)
Computes the Kullback-Leibler divergence between two random vectors distributed according to multivariate Cauchy distributions (MCD) with zero location vector.
kldcauchy(Sigma1, Sigma2, eps = 1e-06)
kldcauchy(Sigma1, Sigma2, eps = 1e-06)
Sigma1 |
symmetric, positive-definite matrix. The scatter matrix of the first distribution. |
Sigma2 |
symmetric, positive-definite matrix. The scatter matrix of the second distribution. |
eps |
numeric. Precision for the computation of the partial derivative of the Lauricella |
Given , a random vector of
distributed according to the MCD
with parameters
and
, a random vector of
distributed according to the MCD
with parameters
.
Let the eigenvalues of the square matrix
sorted in increasing order:
Depending on the values of these eigenvalues,
the computation of the Kullback-Leibler divergence of from
is given by:
if and
:
if :
if :
where is the Lauricella
-hypergeometric function defined for
variables:
A numeric value: the Kullback-Leibler divergence between the two distributions,
with two attributes attr(, "epsilon")
(precision of the partial derivative of the Lauricella -hypergeometric function,see Details)
and
attr(, "k")
(number of iterations).
Pierre Santagostini, Nizar Bouhlel
N. Bouhlel, D. Rousseau, A Generic Formula and Some Special Cases for the Kullback–Leibler Divergence between Central Multivariate Cauchy Distributions. Entropy, 24, 838, July 2022. doi:10.3390/e24060838
Sigma1 <- matrix(c(1, 0.6, 0.2, 0.6, 1, 0.3, 0.2, 0.3, 1), nrow = 3) Sigma2 <- matrix(c(1, 0.3, 0.1, 0.3, 1, 0.4, 0.1, 0.4, 1), nrow = 3) kldcauchy(Sigma1, Sigma2) kldcauchy(Sigma2, Sigma1) Sigma1 <- matrix(c(0.5, 0, 0, 0, 0.4, 0, 0, 0, 0.3), nrow = 3) Sigma2 <- diag(1, 3) # Case when all eigenvalues of Sigma1 %*% solve(Sigma2) are < 1 kldcauchy(Sigma1, Sigma2) # Case when all eigenvalues of Sigma1 %*% solve(Sigma2) are > 1 kldcauchy(Sigma2, Sigma1)
Sigma1 <- matrix(c(1, 0.6, 0.2, 0.6, 1, 0.3, 0.2, 0.3, 1), nrow = 3) Sigma2 <- matrix(c(1, 0.3, 0.1, 0.3, 1, 0.4, 0.1, 0.4, 1), nrow = 3) kldcauchy(Sigma1, Sigma2) kldcauchy(Sigma2, Sigma1) Sigma1 <- matrix(c(0.5, 0, 0, 0, 0.4, 0, 0, 0, 0.3), nrow = 3) Sigma2 <- diag(1, 3) # Case when all eigenvalues of Sigma1 %*% solve(Sigma2) are < 1 kldcauchy(Sigma1, Sigma2) # Case when all eigenvalues of Sigma1 %*% solve(Sigma2) are > 1 kldcauchy(Sigma2, Sigma1)
Computes the logarithm of the Pochhammer symbol.
lnpochhammer(x, n)
lnpochhammer(x, n)
x |
numeric. |
n |
positive integer. |
The Pochhammer symbol is given by:
So, if :
If ,
Numeric value. The logarithm of the Pochhammer symbol.
Pierre Santagostini, Nizar Bouhlel
lnpochhammer(2, 0) lnpochhammer(2, 1) lnpochhammer(2, 3)
lnpochhammer(2, 0) lnpochhammer(2, 1) lnpochhammer(2, 3)
Plots the probability density of the multivariate Cauchy distribution with 2 variables
with location parameter mu
and scatter matrix Sigma
.
plotmcd(mu, Sigma, xlim = c(mu[1] + c(-10, 10)*Sigma[1, 1]), ylim = c(mu[2] + c(-10, 10)*Sigma[2, 2]), n = 101, xvals = NULL, yvals = NULL, xlab = "x", ylab = "y", zlab = "f(x,y)", col = "gray", tol = 1e-6, ...)
plotmcd(mu, Sigma, xlim = c(mu[1] + c(-10, 10)*Sigma[1, 1]), ylim = c(mu[2] + c(-10, 10)*Sigma[2, 2]), n = 101, xvals = NULL, yvals = NULL, xlab = "x", ylab = "y", zlab = "f(x,y)", col = "gray", tol = 1e-6, ...)
mu |
length 2 numeric vector. |
Sigma |
symmetric, positive-definite square matrix of order 2. The scatter matrix. |
xlim , ylim
|
x-and y- limits. |
n |
A one or two element vector giving the number of steps in the x and y grid, passed to |
xvals , yvals
|
The values at which to evaluate |
xlab , ylab , zlab
|
The axis labels. |
col |
The color to use for the plot. See |
tol |
tolerance (relative to largest variance) for numerical lack of positive-definiteness in Sigma, for the estimation of the density. see |
... |
Additional arguments to pass to |
Returns invisibly the probability density function.
Pierre Santagostini, Nizar Bouhlel
N. Bouhlel, D. Rousseau, A Generic Formula and Some Special Cases for the Kullback–Leibler Divergence between Central Multivariate Cauchy Distributions. Entropy, 24, 838, July 2022. doi:10.3390/e24060838
dmcd
: probability density of a multivariate Cauchy density
contourmcd
: contour plot of a bivariate Cauchy density.
plot3d.function
: plot a function of two variables.
mu <- c(1, 4) Sigma <- matrix(c(0.8, 0.2, 0.2, 0.2), nrow = 2) plotmcd(mu, Sigma)
mu <- c(1, 4) Sigma <- matrix(c(0.8, 0.2, 0.2, 0.2), nrow = 2) plotmcd(mu, Sigma)
Computes the Pochhammer symbol.
pochhammer(x, n)
pochhammer(x, n)
x |
numeric. |
n |
positive integer. |
The Pochhammer symbol is given by:
Numeric value. The value of the Pochhammer symbol.
Pierre Santagostini, Nizar Bouhlel
pochhammer(2, 0) pochhammer(2, 1) pochhammer(2, 3)
pochhammer(2, 0) pochhammer(2, 1) pochhammer(2, 3)
Produces one or more samples from the multivariate ( variables) Cauchy distribution (MCD)
with location parameter
mu
and scatter matrix Sigma
.
rmcd(n, mu, Sigma, tol = 1e-6)
rmcd(n, mu, Sigma, tol = 1e-6)
n |
integer. Number of observations. |
mu |
length |
Sigma |
symmetric, positive-definite square matrix of order |
tol |
tolerance for numerical lack of positive-definiteness in Sigma (for |
A sample from a MCD with parameters and
can be generated using:
where is a random vector distributed among a centered Gaussian density
with covariance matrix
(generated using
mvrnorm
)
and is distributed among a Chi-squared distribution with 1 degree of freedom.
A matrix with columns and
rows.
Pierre Santagostini, Nizar Bouhlel
dmcd
: probability density of a MCD.
mu <- c(0, 1, 4) sigma <- matrix(c(1, 0.6, 0.2, 0.6, 1, 0.3, 0.2, 0.3, 1), nrow = 3) x <- rmcd(100, mu, sigma) x apply(x, 2, median)
mu <- c(0, 1, 4) sigma <- matrix(c(1, 0.6, 0.2, 0.6, 1, 0.3, 0.2, 0.3, 1), nrow = 3) x <- rmcd(100, mu, sigma) x apply(x, 2, median)