Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WishartTriL does not support df \in (k - 1, k) #1987

Open
georgematheos opened this issue Jan 31, 2025 · 0 comments
Open

WishartTriL does not support df \in (k - 1, k) #1987

georgematheos opened this issue Jan 31, 2025 · 0 comments

Comments

@georgematheos
Copy link

georgematheos commented Jan 31, 2025

My understanding is that the Wishart distribution is well defined so long as df > k - 1. k is the dimension parameter, so the Wishart distribution has support over k x k matrices. df is the "degrees of freedom" parameter. However, the docs for WishartTriL indicate that it only supports df >= k. And when I try constructing a WishartTriL with k > df > k - 1, I get an error.

The fact that Wishart is supported for any df > k - 1 seems to be indicated in the distribution overview section of the wikipedia for InverseWishart, and in the wikipedia for the Wishart distribution, in the last paragraph of the "Spectral Density" section.

I have in mind that it would be useful to use a Wishart with df < k in order to express a very uncertain prior over the covariance of a multivariate normal distribution.

The scipy docs suggest that scipy's Wishart distribution supports construction with k - 1 < df < k. They do note, however, that the behavior of their sampling algorithm can create invalid samples sometimes when df < k, and advise users to check for invalid sample generation.

Here is a code example showing the problem:

import tensorflow_probability.substrates.jax.distributions as tfd
import jax.numpy as jnp

nu = 0.01
Lambda = jnp.array([[1.0]])
X = jnp.array([[0.5]])

scale_tril = jnp.linalg.cholesky(Lambda)
tfd.WishartTriL(nu, scale_tril)

Constructing this distribution causes an error.

This is despite the fact that it is possible to construct and evaluate logpdfs of the following Gamma distribution, even though (if I understand correctly) this 1D Gamma is equivalent to the above Wishart distribution:

tfd.Gamma(nu / 2, 1 / (2 * Lambda[0, 0]))

(You can check this equivalence by changing nu to something greater than 1, so you can construct the Wishart distribution, and test that the logpdf values for the two distributions are the same.)

I am using tensorflow_probability version 0.23.0.

Thank you for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant