Perbedaan Kullback – Leibler antara dua distribusi gamma


15

Memilih parameter parameter distribusi gamma Γ(b,c) oleh pdf g(x;b,c)=1Γ(c)xc1bcex/b Perbedaan Kullback-Leibler antaraΓ(bq,cq)danΓ(bp,cp)diberikan oleh [1] sebagai

KLGa(bq,cq;bp,cp)=(cq1)Ψ(cq)logbqcqlogΓ(cq)+logΓ(cp)+cplogbp(cp1)(Ψ(cq)+logbq)+bqcqbp

Saya menduga bahwa Ψ(x):=Γ(x)/Γ(x) adalah fungsi digamma .

Ini diberikan tanpa derivasi. Saya tidak dapat menemukan referensi yang menghasilkan ini. Ada bantuan? Referensi yang baik sudah cukup. Bagian yang sulit adalah mengintegrasikan logx terhadap gamma pdf.

[1] WD Penny, KL-Divergensi kepadatan Normal, Gamma, Dirichlet, dan Wishart , Tersedia di: www.fil.ion.ucl.ac.uk/~wpenny/publications/densities.ps


2
Mengambil turunan dari pdf sehubungan dengan memperkenalkan faktor l o g ( x ) Anda mencari: bahwa ini mengapa digamma menunjukkan up. clog(x)
whuber

Jika Anda menemukan Pierre Baldi dan Laurent Itti (2010) “Dari bit and wow: Sebuah teori kejutan Bayesian dengan aplikasi yang menarik perhatian” Neural Networks 23: 649-666, Anda akan menemukan Persamaan 73 memberikan KL perbedaan antara dua gamma pdfs. Berhati-hatilah, sepertinya formula ini salah cetak.
Tuan Clarinet

Saya mencari solusi untuk masalah yang sama dan menemukan ini satu berguna.
Yi Yang

Jawaban:


15

Divergensi KL adalah perbedaan integral dari bentuk

$$ \ eqalign {I (a, b, c, d) & = \ int_0 ^ {\ infty} \ log \ kiri (\ frac {e ^ {- x / a} x ^ {b-1}} {a ^ b \ Gamma (b)} \ kanan) \ frac {e ^ {- x / c} x ^ {d-1}} {c ^ d \ Gamma (d)} dx \

& = - \ frac {1} {a} \ int_0 ^ \ infty \ frac {x ^ de ^ {- x / c}} {c ^ d \ Gamma (d)} \, dx - \ log (a ^ b \ Gamma (b)) \ ​​int_0 ^ \ infty \ frac {e ^ {- x / c} x ^ {d-1}} {c ^ d \ Gamma (d)} \, dx \ & \ quad + (b- 1) \ int_0 ^ \ infty \ log (x) \ frac {e ^ {- x / c} x ^ {d-1}} {c ^ d \ Gamma (d)} \, dx \

& = - \ frac {cd} {a} - \ log (a ^ b \ Gamma (b)) + (b-1) \ int_0 ^ \ infty \ log (x) \ frac {e ^ {- x / c } x ^ {d-1}} {c ^ d \ Gamma (d)} \, dx} $$

Kami hanya harus berurusan dengan integral kanan, yang diperoleh dengan mengamati

dΓ(d)=d0ex/cxd1cddx=d0ex/c(x/c)d1cdx=0ex/cxd1cdlogxcdx=0log(x)ex/cxd1cddxlog(c)Γ(d).

Whence

b1Γ(d)0log(x)ex/c(x/c)d1dx=(b1)Γ(d)Γ(d)+(b1)log(c).

Plugging into the preceding yields

I(a,b,c,d)=cdalog(abΓ(b))+(b1)Γ(d)Γ(d)+(b1)log(c).

The KL divergence between Γ(c,d) and Γ(a,b) equals I(c,d,c,d)I(a,b,c,d), which is straightforward to assemble.


Implementation Details

Gamma functions grow rapidly, so to avoid overflow don't compute Gamma and take its logarithm: instead use the log-Gamma function that will be found in any statistical computing platform (including Excel, for that matter).

The ratio Γ(d)/Γ(d) is the logarithmic derivative of Γ, generally called ψ, the digamma function. If it's not available to you, there are relatively simple ways to approximate it, as described in the Wikipedia article.

Here, to illustrate, is a direct R implementation of the formula in terms of I. This does not exploit an opportunity to simplify the result algebraically, which would make it a little more efficient (by eliminating a redundant calculation of ψ).

#
# `b` and `d` are Gamma shape parameters and
# `a` and `c` are scale parameters.
# (All, therefore, must be positive.)
#
KL.gamma <- function(a,b,c,d) {
  i <- function(a,b,c,d)
    - c * d / a - b * log(a) - lgamma(b) + (b-1)*(psigamma(d) + log(c))
  i(c,d,c,d) - i(a,b,c,d)
}
print(KL.gamma(1/114186.3, 202, 1/119237.3, 195), digits=12)

2
Good answer. Thanks! I believe that there is a sign error however in the fourth equality. Also, your gamma pdf should have an extra factor of 'c' in the denominator. Would you like me to edit it?
Ian Langmore

@Ian You're right; I usually write the measure as dx/x and by not doing that I omitted that extra factor of c. Good catch on the sign mistake. If you would like to make the edits, feel free!
whuber

2
I made the corrections.
Ian Langmore

10

The Gamma distribution is in the exponential family because its density can be expressed as:

f(xθ)=exp(η(θ)T(x)g(θ)+h(x))

Looking at the Gamma density function, its log-normalizer is

g(θ)=log(Γ(c))+clog(b)
with natural parameters
θ=[c11b]

All distributions in the exponential family have KL divergence:

KL(q;p)=g(θp)g(θq)(θpθq)g(θq).

There's a really nice proof of that in:

Frank Nielsen, École Polytechnique, and Richard Nock, Entropies and cross-entropies of exponential families.


Didn't know this. Just a quick question - the g(.) function, does it have to be the same for θp as for θq? So for example, would the above formula be valid for KL divergence of normal pdf from gamma pdf?
probabilityislogic

1
Yes, this formula is for two distributions in the same exponential family.
Neil G
Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.