İki gama dağılımı arasındaki Kullback – Leibler ayrılığı


15

Gama dağılımını Γ(b,c) pdf g ( x ; b , c ) = 1 ile parametreleştirmeyi seçmeull(bq,cq)veΓ(bp,cp) arasındaki Kullback-Leibler sapması[1]g(x;b,c)=1Γ(c)xc1bcex/bΓ(bq,cq)Γ(bp,cp)

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

Bunu tahmin ediyorum olan digamma işlevi . Ψ(x):=Γ(x)/Γ(x)

Bu türetilmeden verilir. Bunu türeyen hiçbir referans bulamıyorum. Herhangi bir yardım? İyi bir referans yeterli olacaktır. Zor kısmı bir gama pdf'ye entegre etmektir .logx

[1] WD Penny, KL-Normal, Gama, Dirichlet ve Wishart yoğunluklarının sapmaları, www.philion.ucl.ac.uk/~wpenny/publications/densities.ps


2
İle ilgili olarak pdf türev alma faktör sunmakta l O g ( x ) Aradığınız: 's bu yüzden digamma gösterir kadar. clog(x)
whuber

Pierre Baldi ve Laurent Itti (2010) ile karşılaşırsanız, “Bit ve wows: Dikkat çekici uygulamalarla bir Bayesian sürpriz teorisi” Neural Networks 23: 649-666, Denklem 73'ün iki gama pdfs arasında bir KL sapması verdiğini göreceksiniz. Bununla birlikte, formül yanlış yazdırılmış gibi görünüyor.
Bay Clarinet

Aynı soruna bir çözüm arayan ve bu bulacağım bir yararlıdır.
Johnny

Yanıtlar:


15

KL sapması, formun integrallerinin bir farkıdır

$$ \ eqalign {I (a, b, c, d) & = \ int_0 ^ {\ infty} \ log \ left (\ frac {e ^ {- x / a} x ^ {b-1}} {a ^ b \ Gamma (b)} \ sağ) \ 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} $$

Sadece gözlemleyerek elde edilen sağ el integrali ile uğraşmak zorundayız.

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

Nereden

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
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.