Title: | Compute Moments Related to Beta-Wishart and Inverse Beta-Wishart Distributions |
---|---|
Description: | Provides functions for computing moments and coefficients related to the Beta-Wishart and Inverse Beta-Wishart distributions. It includes functions for calculating the expectation of matrix-valued functions of the Beta-Wishart distribution, coefficient matrices C_k and H_k, expectation of matrix-valued functions of the inverse Beta-Wishart distribution, and coefficient matrices \tilde{C}_k and \tilde{H}_k. For more details, refer Hillier and Kan (2024) <https://www-2.rotman.utoronto.ca/~kan/papers/wishmom.pdf>, "On the Expectations of Equivariant Matrix-valued Functions of Wishart and Inverse Wishart Matrices". |
Authors: | Raymond Kan [aut, cre], Preston Liang [aut] |
Maintainer: | Raymond Kan <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.0 |
Built: | 2024-11-26 06:43:27 UTC |
Source: | CRAN |
and
This function computes the coefficients of the denominator polynomial for the elements of
and
.
The function returns a vector containing the coefficients in descending powers of
, with the last element being the coefficient of
.
denpoly(k, alpha = 2)
denpoly(k, alpha = 2)
k |
The order of the polynomial (a positive integer) |
alpha |
The type of Wishart distribution
|
A vector containing the coefficients of the denominator
polynomial in descending powers of for the elements of
and
.
# Example 1: Compute the denominator polynomial for k = 3, alpha = 2 # Output corresponds to the polynomial n1^5-3n1^4-8n1^3+12n1^2+16n1, # where n1 is \eqn{\tilde{n}} denpoly(3) # Example 2: Compute the denominator polynomial for k = 2, alpha = 1 # Output corresponds to the polynomial n1^3-n1, where n1 is \eqn{\tilde{n}} denpoly(2, alpha = 1)
# Example 1: Compute the denominator polynomial for k = 3, alpha = 2 # Output corresponds to the polynomial n1^5-3n1^4-8n1^3+12n1^2+16n1, # where n1 is \eqn{\tilde{n}} denpoly(3) # Example 2: Compute the denominator polynomial for k = 2, alpha = 1 # Output corresponds to the polynomial n1^3-n1, where n1 is \eqn{\tilde{n}} denpoly(2, alpha = 1)
to
for a beta-Wishart Distribution, but without
on the diagonalThis function computes the matrix that maps to
when
.
dkmap(k, alpha = 2)
dkmap(k, alpha = 2)
k |
The order of the mapping matrix |
alpha |
The type of beta-Wishart distribution (
|
A matrix that maps to
, but without
on the diagonal.
# Example 1: Compute the mapping matrix for k = 2, real Wishart dkmap(2) # Example 2: Compute the mapping matrix for k = 1, complex Wishart dkmap(1, 1) # Example 3: Compute the mapping matrix for k = 2, quaternion Wishart dkmap(2, 1/2)
# Example 1: Compute the mapping matrix for k = 2, real Wishart dkmap(2) # Example 2: Compute the mapping matrix for k = 1, complex Wishart dkmap(1, 1) # Example 3: Compute the mapping matrix for k = 2, quaternion Wishart dkmap(2, 1/2)
This function generates all integer partitions of a given integer k
in reverse lexicographical order.
The function is adapted from "Algorithm ZS1" described in Zoghbi and Stojmenovic (1998),
"Fast Algorithms for Generating Integer Partitions", International Journal of Computer Mathematics,
Volume 70, Issue 2, pages 319-332.
ip_desc(k)
ip_desc(k)
k |
An integer to be partitioned |
A matrix where each row represents an integer partition of k
.
The partitions are listed in reverse lexicographical order.
Zoghbi, A., & Stojmenovic, I. (1998). Fast Algorithms for Generating Integer Partitions. International Journal of Computer Mathematics, 70(2), 319-332. DOI: 10.1080/00207169808804755
# Example 1: ip_desc(3) # Example 2: ip_desc(5)
# Example 1: ip_desc(3) # Example 2: ip_desc(5)
This function computes the inverse of a coefficient matrix
that allows us to compute the expected value of a power-sum symmetric
function of
, where
.
iwish_ps(k, alpha = 2)
iwish_ps(k, alpha = 2)
k |
The order of the |
alpha |
The type of Wishart distribution (
|
Inverse of a coefficient matrix that allows us
to compute the expected value of a power-sum symmetric function of
,
where
. The matrix is represented as a
3-dimensional array where each slice along the third dimension represents
a coefficient matrix of the polynomial in descending powers of
.
# Example 1: iwish_ps(3) # For real Wishart distribution with k = 3 # Example 2: iwish_ps(4, 1) # For complex Wishart distribution with k = 4 # Example 3: iwish_ps(2, 1/2) # For quaternion Wishart distribution with k = 2
# Example 1: iwish_ps(3) # For real Wishart distribution with k = 3 # Example 2: iwish_ps(4, 1) # For complex Wishart distribution with k = 4 # Example 3: iwish_ps(2, 1/2) # For quaternion Wishart distribution with k = 2
This function computes the coefficient matrix for
.
iwish_psr(k, alpha = 2)
iwish_psr(k, alpha = 2)
k |
The order of the |
alpha |
The type of Wishart distribution (
|
A list with two elements:
c
: A 3-dimensional array containing the coefficient matrices of the numerator of in descending powers of
, where
den
: A vector containing the coefficients of the denominator of , in descending powers of
# Example 1: iwish_psr(2) # For real Wishart distribution with k = 2 # Example 2: iwish_psr(4, 1) # For complex Wishart distribution with k = 4 # Example 3: iwish_psr(2, 1/2) # For quaterion Wishart distribution with k = 2
# Example 1: iwish_psr(2) # For real Wishart distribution with k = 2 # Example 2: iwish_psr(4, 1) # For complex Wishart distribution with k = 4 # Example 3: iwish_psr(2, 1/2) # For quaterion Wishart distribution with k = 2
When iw = 0
, the function calculates ,
where
. When
iw != 0
,
the function calculates .
iwishmom(n, S, f, iw = 0, alpha = 2)
iwishmom(n, S, f, iw = 0, alpha = 2)
n |
The degrees of freedom of the beta-Wishart matrix |
S |
The covariance matrix of the beta-Wishart matrix |
f |
A vector of nonnegative integers |
iw |
The power of the inverse beta-Wishart matrix |
alpha |
The type of Wishart distribution
|
When iw = 0
, it returns .
When
iw != 0
, it returns .
# Example 1: For E[tr(W^{-1})^2] with W ~ W_m^1(n,S), # where n and S are defined below: n <- 20 S <- matrix(c(25, 49, 49, 109), nrow=2, ncol=2) iwishmom(n, S, 2) # iw = 0, for real Wishart distribution # Example 2: For E[tr(W^{-1})^2*tr(W^{-3})W^{-2}] with W ~ W_m^1(n,S), # where n and S are defined below: n <- 20 S <- matrix(c(25, 49, 49, 109), nrow=2, ncol=2) iwishmom(n, S, c(2, 0, 1), 2, 2) # iw = 2, for real Wishart distribution # Example 3: For E[tr(W^{-1})^2*tr(W^{-3})] with W ~ W_m^2(n,S), # where n and S are defined below: # Hermitian S for the complex case n <- 20 S <- matrix(c(25, 49 + 2i, 49 - 2i, 109), nrow=2, ncol=2) iwishmom(n, S, c(2, 0, 1), 0, 1) # iw = 0, for complex Wishart distribution # Example 4: For E[tr(W^{-1})*tr(W^{-2})^2*tr(W^{-3})^2*W^{-1}] with W ~ W_m^2(n,S), # where n and S are defined below: n <- 30 S <- matrix(c(25, 49 + 2i, 49 - 2i, 109), nrow=2, ncol=2) iwishmom(n, S, c(1, 2, 2), 1, 1) # iw = 1, for complex Wishart distribution
# Example 1: For E[tr(W^{-1})^2] with W ~ W_m^1(n,S), # where n and S are defined below: n <- 20 S <- matrix(c(25, 49, 49, 109), nrow=2, ncol=2) iwishmom(n, S, 2) # iw = 0, for real Wishart distribution # Example 2: For E[tr(W^{-1})^2*tr(W^{-3})W^{-2}] with W ~ W_m^1(n,S), # where n and S are defined below: n <- 20 S <- matrix(c(25, 49, 49, 109), nrow=2, ncol=2) iwishmom(n, S, c(2, 0, 1), 2, 2) # iw = 2, for real Wishart distribution # Example 3: For E[tr(W^{-1})^2*tr(W^{-3})] with W ~ W_m^2(n,S), # where n and S are defined below: # Hermitian S for the complex case n <- 20 S <- matrix(c(25, 49 + 2i, 49 - 2i, 109), nrow=2, ncol=2) iwishmom(n, S, c(2, 0, 1), 0, 1) # iw = 0, for complex Wishart distribution # Example 4: For E[tr(W^{-1})*tr(W^{-2})^2*tr(W^{-3})^2*W^{-1}] with W ~ W_m^2(n,S), # where n and S are defined below: n <- 30 S <- matrix(c(25, 49 + 2i, 49 - 2i, 109), nrow=2, ncol=2) iwishmom(n, S, c(1, 2, 2), 1, 1) # iw = 1, for complex Wishart distribution
When iw = 0
, the function returns an analytical expression of
, where
.
When
iw != 0
, the function returns an analytical expression of
.
For a given
f
, iw
, and alpha
, this function provides the aforementioned
expectations in terms of the variables and
.
iwishmom_sym(f, iw = 0, alpha = 2, latex = FALSE)
iwishmom_sym(f, iw = 0, alpha = 2, latex = FALSE)
f |
A vector of nonnegative integers |
iw |
The power of the inverse beta-Wishart matrix |
alpha |
The type of Wishart distribution
|
latex |
A Boolean indicating whether the output will be a LaTeX string or dataframe (FALSE by default) |
When iw = 0
, it returns an analytical expression of
.
When
iw != 0
, it returns an analytical expression of
.
If
latex = FALSE
, the output is a data frame that stores the
coefficients for calculating the result. If latex = TRUE
, the
output is a LaTeX formatted string of the result in terms of
and
.
# Example 1: For E[tr(W^{-1})^4] with W ~ W_m^1(n,Sigma), represented as a dataframe: iwishmom_sym(4) # iw = 0, for real Wishart distribution # Example 2: For E[tr(W^{-1})*tr(W^{-2})W^{-1}] with W ~ W_m^1(n,S), represented as a dataframe: iwishmom_sym(c(1, 1), 1) # iw = 1, for real Wishart distribution # Example 3: For E[tr(W^{-1})^4] with W ~ W_m^2(n,S), represented as a LaTeX string: # Using writeLines() to format writeLines(iwishmom_sym(4, 0, 1, latex=TRUE)) # iw = 0, for complex Wishart distribution # Example 4: For E[tr(W^{-1})*tr(W^{-2})W^{-1}] with W ~ W_m^2(n,S), represented as a LaTeX string: # Using writeLines() to format writeLines(iwishmom_sym(c(1, 1), 1, 1, latex=TRUE)) # iw = 1, for real Wishart distribution
# Example 1: For E[tr(W^{-1})^4] with W ~ W_m^1(n,Sigma), represented as a dataframe: iwishmom_sym(4) # iw = 0, for real Wishart distribution # Example 2: For E[tr(W^{-1})*tr(W^{-2})W^{-1}] with W ~ W_m^1(n,S), represented as a dataframe: iwishmom_sym(c(1, 1), 1) # iw = 1, for real Wishart distribution # Example 3: For E[tr(W^{-1})^4] with W ~ W_m^2(n,S), represented as a LaTeX string: # Using writeLines() to format writeLines(iwishmom_sym(4, 0, 1, latex=TRUE)) # iw = 0, for complex Wishart distribution # Example 4: For E[tr(W^{-1})*tr(W^{-2})W^{-1}] with W ~ W_m^2(n,S), represented as a LaTeX string: # Using writeLines() to format writeLines(iwishmom_sym(c(1, 1), 1, 1, latex=TRUE)) # iw = 1, for real Wishart distribution
This function computes the coefficient matrix , which
is a matrix of constants that allows us to obtain
,
where
and
.
qk_coeff(k, alpha = 2)
qk_coeff(k, alpha = 2)
k |
The order of the |
alpha |
The type of Wishart distribution (
|
, a matrix that allows us to obtain
,
where
and
.
The matrix is represented as a 3-dimensional array where each slice along the third
dimension represents a coefficient matrix of the polynomial in descending powers of
.
# Example 1: qk_coeff(2) # For real Wishart distribution with k = 2 # Example 2: qk_coeff(3, 1) # For complex Wishart distribution with k = 3 # Example 3: qk_coeff(2, 1/2) # For quaternion Wishart distribution with k = 2
# Example 1: qk_coeff(2) # For real Wishart distribution with k = 2 # Example 2: qk_coeff(3, 1) # For complex Wishart distribution with k = 3 # Example 3: qk_coeff(2, 1/2) # For quaternion Wishart distribution with k = 2
This function computes the inverse of the coefficient matrix
qkn_coeff(k, alpha = 2)
qkn_coeff(k, alpha = 2)
k |
The order of the |
alpha |
The type of beta-Wishart distribution (
|
Inverse of a coefficient matrix that allows us to
obtain
, where
and
. The matrix is represented as a
3-dimensional array where each slice along the third dimension represents
a coefficient matrix of the polynomial in descending powers of
.
# Example 1: qkn_coeff(2) # For real Wishart distribution with k = 2 # Example 2: qkn_coeff(3, 1) # For complex Wishart distribution with k = 3 # Example 3: qkn_coeff(2, 1/2) # For quaternion Wishart distribution with k = 2
# Example 1: qkn_coeff(2) # For real Wishart distribution with k = 2 # Example 2: qkn_coeff(3, 1) # For complex Wishart distribution with k = 3 # Example 3: qkn_coeff(2, 1/2) # For quaternion Wishart distribution with k = 2
This function computes the coefficient matrix for for
.
qkn_coeffr(k, alpha = 2)
qkn_coeffr(k, alpha = 2)
k |
The order of the |
alpha |
The type of Wishart distribution (
|
A list with two elements:
c
: A 3-dimensional array containing the coefficient matrices of the numerator of in descending powers of
, where
.
den
: A vector containing the coefficients of the denominator of , in descending powers of
.
# Example 1: qkn_coeffr(2) # For real Wishart distribution with k = 2 # Example 2: qkn_coeffr(3, 1) # For complex Wishart distribution with k = 3 # Example 3: qkn_coeffr(2, 1/2) # For quaternion Wishart distribution with k = 2
# Example 1: qkn_coeffr(2) # For real Wishart distribution with k = 2 # Example 2: qkn_coeffr(3, 1) # For complex Wishart distribution with k = 3 # Example 3: qkn_coeffr(2, 1/2) # For quaternion Wishart distribution with k = 2
This function computes the coefficient matrix that allows us to compute
the expected value of a power-sum symmetric function of
, where
.
wish_ps(k, alpha = 2)
wish_ps(k, alpha = 2)
k |
The order of the |
alpha |
The type of Wishart distribution (
|
A coefficient matrix that allows us to compute
the expected value of a power-sum symmetric function of
,
where
. The matrix is represented as a
3-dimensional array where each slice along the third dimension represents
a coefficient matrix of the polynomial in descending powers of
.
# Example 1: wish_ps(3) # For real Wishart distribution with k = 3 # Example 2: wish_ps(4, 1) # For complex Wishart distribution with k = 4 # Example 3: wish_ps(2, 1/2) # For quaternion Wishart distribution with k = 2
# Example 1: wish_ps(3) # For real Wishart distribution with k = 3 # Example 2: wish_ps(4, 1) # For complex Wishart distribution with k = 4 # Example 3: wish_ps(2, 1/2) # For quaternion Wishart distribution with k = 2
When iw = 0
, the function calculates ,
where
. When
iw != 0
,
the function calculates
wishmom(n, S, f, iw = 0, alpha = 2)
wishmom(n, S, f, iw = 0, alpha = 2)
n |
The degrees of freedom of the beta-Wishart matrix |
S |
The covariance matrix of the beta-Wishart matrix |
f |
A vector of nonnegative integers |
iw |
The power of the inverse beta-Wishart matrix |
alpha |
The type of Wishart distribution
|
When iw = 0
, it returns .
When
iw != 0
, it returns .
# Example 1: For E[tr(W)^4] with W ~ W_m^1(n,S), # where n and S are defined below: n <- 20 S <- matrix(c(25, 49, 49, 109), nrow=2, ncol=2) wishmom(n, S, 4) # iw = 0, for real Wishart distribution # Example 2: For E[tr(W)^2*tr(W^3)W^2] with W ~ W_m^1(n,S), # where n and S are defined below: n <- 20 S <- matrix(c(25, 49, 49, 109), nrow=2, ncol=2) wishmom(n, S, c(2, 0, 1), 2, 2) # iw = 2, for real Wishart distribution # Example 3: For E[tr(W)^2*tr(W^3)] with W ~ W_m^2(n,S), # where n and S are defined below: # Hermitian S for the complex case n <- 20 S <- matrix(c(25, 49 + 2i, 49 - 2i, 109), nrow=2, ncol=2) wishmom(n, S, c(2, 0, 1), 0, 1) # iw = 0, for complex Wishart distribution # Example 4: For E[tr(W)*tr(W^2)^2*tr(W^3)^2*W] with W ~ W_m^2(n,S), # where n and S are defined below: n <- 20 S <- matrix(c(25, 49 + 2i, 49 - 2i, 109), nrow=2, ncol=2) wishmom(n, S, c(1, 2, 2), 1, 1) # iw = 1, for complex Wishart distribution
# Example 1: For E[tr(W)^4] with W ~ W_m^1(n,S), # where n and S are defined below: n <- 20 S <- matrix(c(25, 49, 49, 109), nrow=2, ncol=2) wishmom(n, S, 4) # iw = 0, for real Wishart distribution # Example 2: For E[tr(W)^2*tr(W^3)W^2] with W ~ W_m^1(n,S), # where n and S are defined below: n <- 20 S <- matrix(c(25, 49, 49, 109), nrow=2, ncol=2) wishmom(n, S, c(2, 0, 1), 2, 2) # iw = 2, for real Wishart distribution # Example 3: For E[tr(W)^2*tr(W^3)] with W ~ W_m^2(n,S), # where n and S are defined below: # Hermitian S for the complex case n <- 20 S <- matrix(c(25, 49 + 2i, 49 - 2i, 109), nrow=2, ncol=2) wishmom(n, S, c(2, 0, 1), 0, 1) # iw = 0, for complex Wishart distribution # Example 4: For E[tr(W)*tr(W^2)^2*tr(W^3)^2*W] with W ~ W_m^2(n,S), # where n and S are defined below: n <- 20 S <- matrix(c(25, 49 + 2i, 49 - 2i, 109), nrow=2, ncol=2) wishmom(n, S, c(1, 2, 2), 1, 1) # iw = 1, for complex Wishart distribution
When iw = 0
, the function returns an analytical expression of
, where
.
When
iw != 0
, the function returns an analytical expression of
.
For a given
f
, iw
, and alpha
, this function provides the aforementioned
expectations in terms of the variables and
.
wishmom_sym(f, iw = 0, alpha = 2, latex = FALSE)
wishmom_sym(f, iw = 0, alpha = 2, latex = FALSE)
f |
A vector of nonnegative integers |
iw |
The power of the beta-Wishart matrix |
alpha |
The type of Wishart distribution
|
latex |
A Boolean indicating whether the output will be a LaTeX string or a dataframe (FALSE by default) |
When iw = 0
, it returns an analytical expression of
.
When
iw != 0
, it returns an analytical expression of
.
If
latex = FALSE
, the output is a data frame that stores the coefficients
for calculating the result. If latex = TRUE
, the output is a LaTeX
formatted string of the result in terms of and
.
# Example 1: For E[tr(W)^4] with W ~ W_m^1(n,Sigma), represented as a dataframe: wishmom_sym(4) # iw = 0, for real Wishart distribution # Example 2: For E[tr(W)*tr(W^2)W] with W ~ W_m^1(n,S), represented as a dataframe: wishmom_sym(c(1, 1), 1) # iw = 1, for real Wishart distribution # Example 3: For E[tr(W)^4] with W ~ W_m^2(n,S), represented as a LaTeX string: # Using writeLines() to format writeLines(wishmom_sym(4, 0, 1, latex=TRUE)) # iw = 0, for complex Wishart distribution # Example 4: For E[tr(W)*tr(W^2)W] with W ~ W_m^2(n,S), represented as a LaTeX string: # Using writeLines() to format writeLines(wishmom_sym(c(1, 1), 1, 1, latex=TRUE)) # iw = 1, for real Wishart distribution
# Example 1: For E[tr(W)^4] with W ~ W_m^1(n,Sigma), represented as a dataframe: wishmom_sym(4) # iw = 0, for real Wishart distribution # Example 2: For E[tr(W)*tr(W^2)W] with W ~ W_m^1(n,S), represented as a dataframe: wishmom_sym(c(1, 1), 1) # iw = 1, for real Wishart distribution # Example 3: For E[tr(W)^4] with W ~ W_m^2(n,S), represented as a LaTeX string: # Using writeLines() to format writeLines(wishmom_sym(4, 0, 1, latex=TRUE)) # iw = 0, for complex Wishart distribution # Example 4: For E[tr(W)*tr(W^2)W] with W ~ W_m^2(n,S), represented as a LaTeX string: # Using writeLines() to format writeLines(wishmom_sym(c(1, 1), 1, 1, latex=TRUE)) # iw = 1, for real Wishart distribution