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

Aperta
#1,987 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Inizia con la costruzione tfd.WishartTriL mostrata nell'issue e verifica come valida df rispetto alla dimensione di scale_tril. Confronta il suo comportamento e logpdf con l'esempio Gamma fornito per k - 1 < df < k. Il lavoro è completato quando la costruzione è valida e il comportamento di logpdf è corretto in quell'intervallo, e il vincolo documentato è stato aggiornato di conseguenza.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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!

Lingua principale
Jupyter Notebook
Stelle
4.4k
Fork
1.1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tensorflow/probability

Tutte le issue di tensorflow/probability

Issue simili

Altre issue su Machine Learning

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.