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

オープン
#1,987 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

issue に示されている tfd.WishartTriL の構築から始め、scale_tril の次元に対して df をどのように検証しているかを確認してください。k - 1 < df < k の場合について、提供されている Gamma の例とその動作および logpdf を比較してください。その範囲で構築が有効で、logpdf が正しく動作し、文書化された制約がそれに応じて更新されていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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!

主要言語
Jupyter Notebook
スター
4.4k
フォーク
1.1k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tensorflow/probability のほかの issue

tensorflow/probability の issue をすべて見る

似ている issue

Machine Learning の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。