Title: | Multivariate Probability Distributions, Statistical Divergence |
---|---|
Description: | Multivariate generalized Gaussian distribution, Multivariate Cauchy distribution, Multivariate t distribution. Distance between two distributions (see N. Bouhlel and A. Dziri (2019): <doi:10.1109/LSP.2019.2915000>, N. Bouhlel and D. Rousseau (2022): <doi:10.3390/e24060838>, N. Bouhlel and D. Rousseau (2023): <doi:10.1109/LSP.2023.3324594>). Manipulation of these multivariate probability distributions. |
Authors: | Pierre Santagostini [aut, cre], Nizar Bouhlel [aut] |
Maintainer: | Pierre Santagostini <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0.10 |
Built: | 2024-12-21 03:45:14 UTC |
Source: | CRAN |
Contour plot of the probability density of a multivariate distribution with 2 variables:
generalized Gaussian distribution (MGGD) with mean vector mu
, dispersion matrix Sigma
and shape parameter beta
Cauchy distribution (MCD) with location parameter mu
and scatter matrix Sigma
distribution (MTD) with location parameter
mu
, scatter matrix Sigma
and degrees of freedom nu
This function uses the contour
function.
contourmvd(mu, Sigma, beta = NULL, nu = NULL, distribution = c("mggd", "mcd", "mtd"), 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 = NULL, sub = NULL, nlevels = 10, levels = pretty(zlim, nlevels), tol = 1e-6, ...)
contourmvd(mu, Sigma, beta = NULL, nu = NULL, distribution = c("mggd", "mcd", "mtd"), 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 = NULL, 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 dispersion matrix. |
beta |
numeric. If |
nu |
numeric. If |
distribution |
character string. The probability distribution. It can be |
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
E. Gomez, M. Gomez-Villegas, H. Marin. A Multivariate Generalization of the Power Exponential Family of Distribution. Commun. Statist. 1998, Theory Methods, col. 27, no. 23, p 589-600. doi:10.1080/03610929808832115
S. Kotz and Saralees Nadarajah (2004), Multivariate Distributions and Their Applications, Cambridge University Press.
plotmvd
: plot of a bivariate generalised Gaussian, Cauchy or density.
dmggd
: probability density of a multivariate generalised Gaussian distribution.
dmcd
: probability density of a multivariate Cauchy distribution.
dmtd
: probability density of a multivariate distribution.
mu <- c(1, 4) Sigma <- matrix(c(0.8, 0.2, 0.2, 0.2), nrow = 2) # Bivariate generalized Gaussian distribution beta <- 0.74 contourmvd(mu, Sigma, beta = beta, distribution = "mggd") # Bivariate Cauchy distribution contourmvd(mu, Sigma, distribution = "mcd") # Bivariate t distribution nu <- 1 contourmvd(mu, Sigma, nu = nu, distribution = "mtd")
mu <- c(1, 4) Sigma <- matrix(c(0.8, 0.2, 0.2, 0.2), nrow = 2) # Bivariate generalized Gaussian distribution beta <- 0.74 contourmvd(mu, Sigma, beta = beta, distribution = "mggd") # Bivariate Cauchy distribution contourmvd(mu, Sigma, distribution = "mcd") # Bivariate t distribution nu <- 1 contourmvd(mu, Sigma, nu = nu, distribution = "mtd")
DistributionsComputes the distance or divergence (Renyi divergence, Bhattacharyya
distance or Hellinger distance) between two random vectors distributed
according to multivariate distributions (MTD) with zero mean vector.
diststudent(nu1, Sigma1, nu2, Sigma2, dist = c("renyi", "bhattacharyya", "hellinger"), bet = NULL, eps = 1e-06)
diststudent(nu1, Sigma1, nu2, Sigma2, dist = c("renyi", "bhattacharyya", "hellinger"), bet = NULL, eps = 1e-06)
nu1 |
numeric. The degrees of freedom of the first distribution. |
Sigma1 |
symmetric, positive-definite matrix. The correlation matrix of the first distribution. |
nu2 |
numeric. The degrees of freedom of the second distribution. |
Sigma2 |
symmetric, positive-definite matrix. The correlation matrix of the second distribution. |
dist |
character. The distance or divergence used.
One of |
bet |
numeric, positive and not equal to 1. Order of the Renyi divergence.
Ignored if |
eps |
numeric. Precision for the computation of the partial derivative of the Lauricella |
Given , a random vector of
distributed according to the MTD
with parameters
and
, a random vector of
distributed according to the MTD
with parameters
.
Let ,
and
the eigenvalues of the square matrix
sorted in increasing order:
The Renyi divergence between and
is:
with given by:
If :
If :
If and
:
where is the Lauricella
-hypergeometric function defined for
variables:
Its computation uses the lauricella
function.
The Bhattacharyya distance is given by:
And the Hellinger distance is given by:
A numeric value: the divergence between the two distributions,
with two attributes attr(, "epsilon")
(precision of the result of the Lauricella -hypergeometric function,see Details)
and
attr(, "k")
(number of iterations).
Pierre Santagostini, Nizar Bouhlel
N. Bouhlel and D. Rousseau (2023), Exact Rényi and Kullback-Leibler Divergences Between Multivariate t-Distributions, IEEE Signal Processing Letters. doi:10.1109/LSP.2023.3324594
nu1 <- 2 Sigma1 <- matrix(c(2, 1.2, 0.4, 1.2, 2, 0.6, 0.4, 0.6, 2), nrow = 3) nu2 <- 4 Sigma2 <- matrix(c(1, 0.3, 0.1, 0.3, 1, 0.4, 0.1, 0.4, 1), nrow = 3) # Renyi divergence diststudent(nu1, Sigma1, nu2, Sigma2, bet = 0.25) diststudent(nu2, Sigma2, nu1, Sigma1, bet = 0.25) # Bhattacharyya distance diststudent(nu1, Sigma1, nu2, Sigma2, dist = "bhattacharyya") diststudent(nu2, Sigma2, nu1, Sigma1, dist = "bhattacharyya") # Hellinger distance diststudent(nu1, Sigma1, nu2, Sigma2, dist = "hellinger") diststudent(nu2, Sigma2, nu1, Sigma1, dist = "hellinger")
nu1 <- 2 Sigma1 <- matrix(c(2, 1.2, 0.4, 1.2, 2, 0.6, 0.4, 0.6, 2), nrow = 3) nu2 <- 4 Sigma2 <- matrix(c(1, 0.3, 0.1, 0.3, 1, 0.4, 0.1, 0.4, 1), nrow = 3) # Renyi divergence diststudent(nu1, Sigma1, nu2, Sigma2, bet = 0.25) diststudent(nu2, Sigma2, nu1, Sigma1, bet = 0.25) # Bhattacharyya distance diststudent(nu1, Sigma1, nu2, Sigma2, dist = "bhattacharyya") diststudent(nu2, Sigma2, nu1, Sigma1, dist = "bhattacharyya") # Hellinger distance diststudent(nu1, Sigma1, nu2, Sigma2, dist = "hellinger") diststudent(nu2, Sigma2, nu1, Sigma1, dist = "hellinger")
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.
estparmcd
: estimation of the parameters of a MCD.
plotmvd
, contourmvd
: plot of the probability density of a bivariate distribution.
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)
Density of the multivariate ( variables) generalized Gaussian distribution (MGGD)
with mean vector
mu
, dispersion matrix Sigma
and shape parameter beta
.
dmggd(x, mu, Sigma, beta, tol = 1e-6)
dmggd(x, mu, Sigma, beta, tol = 1e-6)
x |
length |
mu |
length |
Sigma |
symmetric, positive-definite square matrix of order |
beta |
positive real number. The shape of the distribution. |
tol |
tolerance (relative to largest variance) for numerical lack of positive-definiteness in Sigma. |
The density function of a multivariate generalized Gaussian distribution is given by:
When (univariate case) it becomes:
The value of the density.
Pierre Santagostini, Nizar Bouhlel
E. Gomez, M. Gomez-Villegas, H. Marin. A Multivariate Generalization of the Power Exponential Family of Distribution. Commun. Statist. 1998, Theory Methods, col. 27, no. 23, p 589-600. doi:10.1080/03610929808832115
rmggd
: random generation from a MGGD.
estparmggd
: estimation of the parameters of a MGGD.
plotmvd
, contourmvd
: plot of the probability density of a bivariate distribution.
mu <- c(0, 1, 4) Sigma <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) beta <- 0.74 dmggd(c(0, 1, 4), mu, Sigma, beta) dmggd(c(1, 2, 3), mu, Sigma, beta)
mu <- c(0, 1, 4) Sigma <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) beta <- 0.74 dmggd(c(0, 1, 4), mu, Sigma, beta) dmggd(c(1, 2, 3), mu, Sigma, beta)
DistributionDensity of the multivariate ( variables)
distribution (MTD)
with degrees of freedom
nu
, mean vector mu
and
correlation matrix Sigma
.
dmtd(x, nu, mu, Sigma, tol = 1e-6)
dmtd(x, nu, mu, Sigma, tol = 1e-6)
x |
length |
nu |
numeric. The degrees of freedom. |
mu |
length |
Sigma |
symmetric, positive-definite square matrix of order |
tol |
tolerance (relative to largest variance) for numerical lack of positive-definiteness in Sigma. |
The density function of a multivariate distribution
with
variables is given by:
When (univariate case) it is the location-scale
distribution, with density function:
The value of the density.
Pierre Santagostini, Nizar Bouhlel
S. Kotz and Saralees Nadarajah (2004), Multivariate Distributions and Their Applications, Cambridge University Press.
rmtd
: random generation from a MTD.
estparmtd
: estimation of the parameters of a MTD.
plotmvd
, contourmvd
: plot of the probability density of a bivariate distribution.
nu <- 1 mu <- c(0, 1, 4) Sigma <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) dmtd(c(0, 1, 4), nu, mu, Sigma) dmtd(c(1, 2, 3), nu, mu, Sigma) # Univariate dmtd(1, 3, 0, 1) dt(1, 3)
nu <- 1 mu <- c(0, 1, 4) Sigma <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) dmtd(c(0, 1, 4), nu, mu, Sigma) dmtd(c(1, 2, 3), nu, mu, Sigma) # Univariate dmtd(1, 3, 0, 1) dt(1, 3)
Estimation of the mean vector and correlation matrix of a multivariate Cauchy distribution (MCD).
estparmcd(x, eps = 1e-6)
estparmcd(x, eps = 1e-6)
x |
numeric matrix or data frame. |
eps |
numeric. Precision for the estimation of the parameters. |
The EM method is used to estimate the parameters.
A list of 2 elements:
mu
the mean vector.
Sigma
: symmetric positive-definite matrix. The correlation matrix.
with two attributes attr(, "epsilon")
(precision of the result) and attr(, "k")
(number of iterations).
Pierre Santagostini, Nizar Bouhlel
Doğru, F., Bulut, Y. M. and Arslan, O. (2018). Doubly reweighted estimators for the parameters of the multivariate t-distribution. Communications in Statistics - Theory and Methods. 47. doi:10.1080/03610926.2018.1445861.
dmcd
: probability density of a MTD
rmcd
: random generation from a MTD.
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) # Estimation of the parameters estparmcd(x)
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) # Estimation of the parameters estparmcd(x)
Estimation of the mean vector, dispersion matrix and shape parameter of a multivariate generalized Gaussian distribution (MGGD).
estparmggd(x, eps = 1e-6, display = FALSE, plot = display)
estparmggd(x, eps = 1e-6, display = FALSE, plot = display)
x |
numeric matrix or data frame. |
eps |
numeric. Precision for the estimation of the beta parameter. |
display |
logical. When |
plot |
logical. When |
The parameter is the mean vector of
x
.
The dispersion matrix and shape parameter
are computed
using the method presented in Pascal et al., using an iterative algorithm.
The precision for the estimation of beta
is given by the eps
parameter.
A list of 3 elements:
mu
the mean vector.
Sigma
: symmetric positive-definite matrix. The dispersion matrix.
beta
non-negative numeric value. The shape parameter.
with two attributes attr(, "epsilon")
(precision of the result) and attr(, "k")
(number of iterations).
Pierre Santagostini, Nizar Bouhlel
F. Pascal, L. Bombrun, J.Y. Tourneret, Y. Berthoumieu. Parameter Estimation For Multivariate Generalized Gaussian Distribution. IEEE Trans. Signal Processing, vol. 61 no. 23, p. 5960-5971, Dec. 2013. doi:10.1109/TSP.2013.2282909
dmggd
: probability density of a MGGD.
rmggd
: random generation from a MGGD.
mu <- c(0, 1, 4) Sigma <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) beta <- 0.74 x <- rmggd(100, mu, Sigma, beta) # Estimation of the parameters estparmggd(x)
mu <- c(0, 1, 4) Sigma <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) beta <- 0.74 x <- rmggd(100, mu, Sigma, beta) # Estimation of the parameters estparmggd(x)
DistributionEstimation of the degrees of freedom, mean vector and correlation matrix of a multivariate distribution (MTD).
estparmtd(x, eps = 1e-6, display = FALSE, plot = display)
estparmtd(x, eps = 1e-6, display = FALSE, plot = display)
x |
numeric matrix or data frame. |
eps |
numeric. Precision for the estimation of the parameters. |
display |
logical. When |
plot |
logical. When |
The EM method is used to estimate the parameters.
A list of 3 elements:
nu
non-negative numeric value. The degrees of freedom.
mu
the mean vector.
Sigma
: symmetric positive-definite matrix. The correlation matrix.
with two attributes attr(, "epsilon")
(precision of the result) and attr(, "k")
(number of iterations).
Pierre Santagostini, Nizar Bouhlel
Doğru, F., Bulut, Y. M. and Arslan, O. (2018). Doubly reweighted estimators for the parameters of the multivariate t-distribution. Communications in Statistics - Theory and Methods. 47. doi:10.1080/03610926.2018.1445861.
dmtd
: probability density of a MTD
rmtd
: random generation from a MTD.
nu <- 3 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 <- rmtd(100, nu, mu, Sigma) # Estimation of the parameters estparmggd(x)
nu <- 3 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 <- rmtd(100, nu, mu, Sigma) # Estimation of the parameters estparmggd(x)
Computes the Kullback-Leibler divergence between two random vectors distributed according to centered multivariate distributions:
multivariate generalized Gaussian distribution (MGGD) with zero mean vector, using the kldggd
function
multivariate Cauchy distribution (MCD) with zero location vector, using the kldcauchy
function
multivariate distribution (MTD) with zero mean vector, using the
kldstudent
function
One can also use one of the kldggd
, kldcauchy
or kldstudent
functions, depending on the probability distribution.
kld(Sigma1, Sigma2, distribution = c("mggd", "mcd", "mtd"), beta1 = NULL, beta2 = NULL, nu1 = NULL, nu2 = NULL, eps = 1e-06)
kld(Sigma1, Sigma2, distribution = c("mggd", "mcd", "mtd"), beta1 = NULL, beta2 = NULL, nu1 = NULL, nu2 = NULL, 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. |
distribution |
the probability distribution. It can be |
beta1 , beta2
|
numeric. If |
nu1 , nu2
|
numeric. If |
eps |
numeric.
Precision for the computation of the Lauricella |
A numeric value: the Kullback-Leibler divergence between the two distributions,
with two attributes attr(, "epsilon")
(precision of the Lauricella -hypergeometric function or of its partial derivative)
and
attr(, "k")
(number of iterations).
Pierre Santagostini, Nizar Bouhlel
N. Bouhlel, A. Dziri, Kullback-Leibler Divergence Between Multivariate Generalized Gaussian Distributions. IEEE Signal Processing Letters, vol. 26 no. 7, July 2019. doi:10.1109/LSP.2019.2915000
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
N. Bouhlel and D. Rousseau (2023), Exact Rényi and Kullback-Leibler Divergences Between Multivariate t-Distributions, IEEE Signal Processing Letters. doi:10.1109/LSP.2023.3324594
# Generalized Gaussian distributions beta1 <- 0.74 beta2 <- 0.55 Sigma1 <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) Sigma2 <- matrix(c(1, 0.3, 0.2, 0.3, 0.5, 0.1, 0.2, 0.1, 0.7), nrow = 3) # Kullback-Leibler divergence kl12 <- kld(Sigma1, Sigma2, "mggd", beta1 = beta1, beta2 = beta2) kl21 <- kld(Sigma2, Sigma1, "mggd", beta1 = beta2, beta2 = beta1) print(kl12) print(kl21) # Distance (symmetrized Kullback-Leibler divergence) kldist <- as.numeric(kl12) + as.numeric(kl21) print(kldist) # Cauchy distributions 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) kld(Sigma1, Sigma2, "mcd") kld(Sigma2, Sigma1, "mcd") 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 kld(Sigma1, Sigma2, "mcd") # Case when all eigenvalues of Sigma1 %*% solve(Sigma2) are > 1 kld(Sigma2, Sigma1, "mcd") # Student distributions nu1 <- 2 Sigma1 <- matrix(c(2, 1.2, 0.4, 1.2, 2, 0.6, 0.4, 0.6, 2), nrow = 3) nu2 <- 4 Sigma2 <- matrix(c(1, 0.3, 0.1, 0.3, 1, 0.4, 0.1, 0.4, 1), nrow = 3) # Kullback-Leibler divergence kld(Sigma1, Sigma2, "mtd", nu1 = nu1, nu2 = nu2) kld(Sigma2, Sigma1, "mtd", nu1 = nu2, nu2 = nu1)
# Generalized Gaussian distributions beta1 <- 0.74 beta2 <- 0.55 Sigma1 <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) Sigma2 <- matrix(c(1, 0.3, 0.2, 0.3, 0.5, 0.1, 0.2, 0.1, 0.7), nrow = 3) # Kullback-Leibler divergence kl12 <- kld(Sigma1, Sigma2, "mggd", beta1 = beta1, beta2 = beta2) kl21 <- kld(Sigma2, Sigma1, "mggd", beta1 = beta2, beta2 = beta1) print(kl12) print(kl21) # Distance (symmetrized Kullback-Leibler divergence) kldist <- as.numeric(kl12) + as.numeric(kl21) print(kldist) # Cauchy distributions 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) kld(Sigma1, Sigma2, "mcd") kld(Sigma2, Sigma1, "mcd") 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 kld(Sigma1, Sigma2, "mcd") # Case when all eigenvalues of Sigma1 %*% solve(Sigma2) are > 1 kld(Sigma2, Sigma1, "mcd") # Student distributions nu1 <- 2 Sigma1 <- matrix(c(2, 1.2, 0.4, 1.2, 2, 0.6, 0.4, 0.6, 2), nrow = 3) nu2 <- 4 Sigma2 <- matrix(c(1, 0.3, 0.1, 0.3, 1, 0.4, 0.1, 0.4, 1), nrow = 3) # Kullback-Leibler divergence kld(Sigma1, Sigma2, "mtd", nu1 = nu1, nu2 = nu2) kld(Sigma2, Sigma1, "mtd", nu1 = nu2, nu2 = nu1)
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:
where is given by:
if and
:
if :
if :
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 Kullback- Leibler divergence between two random vectors distributed according to multivariate generalized Gaussian distributions (MGGD) with zero means.
kldggd(Sigma1, beta1, Sigma2, beta2, eps = 1e-06)
kldggd(Sigma1, beta1, Sigma2, beta2, eps = 1e-06)
Sigma1 |
symmetric, positive-definite matrix. The dispersion matrix of the first distribution. |
beta1 |
positive real number. The shape parameter of the first distribution. |
Sigma2 |
symmetric, positive-definite matrix. The dispersion matrix of the second distribution. |
beta2 |
positive real number. The shape parameter of the second distribution. |
eps |
numeric. Precision for the computation of the Lauricella |
Given , a random vector of
(
) distributed according to the MGGD
with parameters
and
, a random vector of
distributed according to the MGGD
with parameters
.
The Kullback-Leibler divergence between and
is given by:
where are the eigenvalues
of the matrix
and is the Lauricella
-hypergeometric function defined for
variables:
This computation uses the lauricella
function.
When (univariate case):
let
, a random variable distributed according to the centered generalized Gaussian distribution
with parameters
and
, a random variable distributed according to the generalized Gaussian distribution
with parameters
.
A numeric value: the Kullback-Leibler divergence between the two distributions,
with two attributes attr(, "epsilon")
(precision of the result of the Lauricella
-hypergeometric Function) and
attr(, "k")
(number of iterations)
except when the distributions are univariate.
Pierre Santagostini, Nizar Bouhlel
N. Bouhlel, A. Dziri, Kullback-Leibler Divergence Between Multivariate Generalized Gaussian Distributions. IEEE Signal Processing Letters, vol. 26 no. 7, July 2019. doi:10.1109/LSP.2019.2915000
dmggd: probability density of a MGGD.
beta1 <- 0.74 beta2 <- 0.55 Sigma1 <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) Sigma2 <- matrix(c(1, 0.3, 0.2, 0.3, 0.5, 0.1, 0.2, 0.1, 0.7), nrow = 3) # Kullback-Leibler divergence kl12 <- kldggd(Sigma1, beta1, Sigma2, beta2) kl21 <- kldggd(Sigma2, beta2, Sigma1, beta1) print(kl12) print(kl21) # Distance (symmetrized Kullback-Leibler divergence) kldist <- as.numeric(kl12) + as.numeric(kl21) print(kldist)
beta1 <- 0.74 beta2 <- 0.55 Sigma1 <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) Sigma2 <- matrix(c(1, 0.3, 0.2, 0.3, 0.5, 0.1, 0.2, 0.1, 0.7), nrow = 3) # Kullback-Leibler divergence kl12 <- kldggd(Sigma1, beta1, Sigma2, beta2) kl21 <- kldggd(Sigma2, beta2, Sigma1, beta1) print(kl12) print(kl21) # Distance (symmetrized Kullback-Leibler divergence) kldist <- as.numeric(kl12) + as.numeric(kl21) print(kldist)
DistributionsComputes the Kullback-Leibler divergence between two random vectors distributed
according to multivariate distributions (MTD) with zero location vector.
kldstudent(nu1, Sigma1, nu2, Sigma2, eps = 1e-06)
kldstudent(nu1, Sigma1, nu2, Sigma2, eps = 1e-06)
nu1 |
numeric. The degrees of freedom of the first distribution. |
Sigma1 |
symmetric, positive-definite matrix. The scatter matrix of the first distribution. |
nu2 |
numeric. The degrees of freedom of the second 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 centered MTD
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:
The Kullback-Leibler divergence of from
is given by:
where is the digamma function (see Special)
and
is given by:
If ,
If ,
If ,
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 and D. Rousseau (2023), Exact Rényi and Kullback-Leibler Divergences Between Multivariate t-Distributions. IEEE Signal Processing Letters, vol. 30, pp. 1672-1676, October 2023. doi:10.1109/LSP.2023.3324594
nu1 <- 2 Sigma1 <- matrix(c(2, 1.2, 0.4, 1.2, 2, 0.6, 0.4, 0.6, 2), nrow = 3) nu2 <- 4 Sigma2 <- matrix(c(1, 0.3, 0.1, 0.3, 1, 0.4, 0.1, 0.4, 1), nrow = 3) kldstudent(nu1, Sigma1, nu2, Sigma2) kldstudent(nu2, Sigma2, nu1, Sigma1)
nu1 <- 2 Sigma1 <- matrix(c(2, 1.2, 0.4, 1.2, 2, 0.6, 0.4, 0.6, 2), nrow = 3) nu2 <- 4 Sigma2 <- matrix(c(1, 0.3, 0.1, 0.3, 1, 0.4, 0.1, 0.4, 1), nrow = 3) kldstudent(nu1, Sigma1, nu2, Sigma2) kldstudent(nu2, Sigma2, nu1, Sigma1)
-Hypergeometric FunctionComputes the Lauricella -hypergeometric function.
lauricella(a, b, g, x, eps = 1e-06)
lauricella(a, b, g, x, eps = 1e-06)
a |
numeric. |
b |
numeric vector. |
g |
numeric. |
x |
numeric vector. |
eps |
numeric. Precision for the nested sums (default 1e-06). |
If is the length of the
and
x
vectors,
the Lauricella -hypergeometric function is given by:
where is the Pochhammer symbol (see
pochhammer
).
If , this sum converges.
Otherwise there is an error.
The eps
argument gives the required precision for its computation.
It is the attr(, "epsilon")
attribute of the returned value.
A numeric value: the value of the Lauricella function,
with two attributes attr(, "epsilon")
(precision of the result) and attr(, "k")
(number of iterations).
Pierre Santagostini, Nizar Bouhlel
N. Bouhlel, A. Dziri, Kullback-Leibler Divergence Between Multivariate Generalized Gaussian Distributions. IEEE Signal Processing Letters, vol. 26 no. 7, July 2019. doi:10.1109/LSP.2019.2915000
N. Bouhlel and D. Rousseau (2023), Exact Rényi and Kullback-Leibler Divergences Between Multivariate t-Distributions. IEEE Signal Processing Letters, vol. 30, pp. 1672-1676, October 2023. doi:10.1109/LSP.2023.3324594
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 a multivariate distribution with 2 variables:
generalized Gaussian distribution (MGGD) with mean vector mu
, dispersion matrix Sigma
and shape parameter beta
Cauchy distribution (MCD) with location parameter mu
and scatter matrix Sigma
distribution (MTD) with location parameter
mu
and scatter matrix Sigma
This function uses the plot3d.function
function.
plotmvd(mu, Sigma, beta = NULL, nu = NULL, distribution = c("mggd", "mcd", "mtd"), 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, ...)
plotmvd(mu, Sigma, beta = NULL, nu = NULL, distribution = c("mggd", "mcd", "mtd"), 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. |
beta |
numeric. If |
nu |
numeric. If |
distribution |
the probability distribution. It can be |
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
E. Gomez, M. Gomez-Villegas, H. Marin. A Multivariate Generalization of the Power Exponential Family of Distribution. Commun. Statist. 1998, Theory Methods, col. 27, no. 23, p 589-600. doi:10.1080/03610929808832115
S. Kotz and Saralees Nadarajah (2004), Multivariate Distributions and Their Applications, Cambridge University Press.
contourmvd
: contour plot of a bivariate generalised Gaussian, Cauchy or density.
dmggd
: Probability density of a multivariate generalised Gaussian distribution.
dmcd
: Probability density of a multivariate Cauchy distribution.
dmtd
: Probability density of a multivariate distribution.
mu <- c(1, 4) Sigma <- matrix(c(0.8, 0.2, 0.2, 0.2), nrow = 2) # Bivariate generalised Gaussian distribution beta <- 0.74 plotmvd(mu, Sigma, beta = beta, distribution = "mggd") # Bivariate Cauchy distribution plotmvd(mu, Sigma, distribution = "mcd") # Bivariate t distribution nu <- 2 plotmvd(mu, Sigma, nu = nu, distribution = "mtd")
mu <- c(1, 4) Sigma <- matrix(c(0.8, 0.2, 0.2, 0.2), nrow = 2) # Bivariate generalised Gaussian distribution beta <- 0.74 plotmvd(mu, Sigma, beta = beta, distribution = "mggd") # Bivariate Cauchy distribution plotmvd(mu, Sigma, distribution = "mcd") # Bivariate t distribution nu <- 2 plotmvd(mu, Sigma, nu = nu, distribution = "mtd")
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
S. Kotz and Saralees Nadarajah (2004), Multivariate Distributions and Their Applications, Cambridge University Press.
dmcd
: probability density of a MCD.
estparmcd
: estimation of the parameters 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)
Produces one or more samples from a multivariate ( variables) generalized Gaussian distribution (MGGD).
rmggd(n = 1 , mu, Sigma, beta, tol = 1e-6)
rmggd(n = 1 , mu, Sigma, beta, tol = 1e-6)
n |
integer. Number of observations. |
mu |
length |
Sigma |
symmetric, positive-definite square matrix of order |
beta |
positive real number. The shape of the distribution. |
tol |
tolerance (relative to largest variance) for numerical lack of positive-definiteness in Sigma. |
A sample from a centered MGGD with dispersion matrix
and shape parameter
can be generated using:
where is a random vector uniformly distributed on the unit sphere and
is such that
is generated from a distribution Gamma
with shape parameter
and scale parameter
.
A matrix with columns and
n
rows.
Pierre Santagostini, Nizar Bouhlel
E. Gomez, M. Gomez-Villegas, H. Marin. A Multivariate Generalization of the Power Exponential Family of Distribution. Commun. Statist. 1998, Theory Methods, col. 27, no. 23, p 589-600. doi:10.1080/03610929808832115
dmggd
: probability density of a MGGD..
estparmggd
: estimation of the parameters of a MGGD.
mu <- c(0, 0, 0) Sigma <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) beta <- 0.74 rmggd(100, mu, Sigma, beta)
mu <- c(0, 0, 0) Sigma <- matrix(c(0.8, 0.3, 0.2, 0.3, 0.2, 0.1, 0.2, 0.1, 0.2), nrow = 3) beta <- 0.74 rmggd(100, mu, Sigma, beta)
DistributionProduces one or more samples from the multivariate ( variables)
distribution (MTD)
with degrees of freedom
nu
, mean vector mu
and
correlation matrix Sigma
.
rmtd(n, nu, mu, Sigma, tol = 1e-6)
rmtd(n, nu, mu, Sigma, tol = 1e-6)
n |
integer. Number of observations. |
nu |
numeric. The degrees of freedom. |
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 MTD 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
degrees of freedom.
A matrix with columns and
rows.
Pierre Santagostini, Nizar Bouhlel
S. Kotz and Saralees Nadarajah (2004), Multivariate Distributions and Their Applications, Cambridge University Press.
dmtd
: probability density of a MTD.
estparmtd
: estimation of the parameters of a MTD.
nu <- 3 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 <- rmtd(10000, nu, mu, Sigma) head(x) dim(x) mu; colMeans(x) nu/(nu-2)*Sigma; var(x)
nu <- 3 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 <- rmtd(10000, nu, mu, Sigma) head(x) dim(x) mu; colMeans(x) nu/(nu-2)*Sigma; var(x)