I assume you can evaluate f and g up to a normalizing constant. Denote f(x)=fu(x)/cf and g(x)=gu(x)/cg.
A consistent estimator that may be used is
DKLˆ(f||g)=[n−1∑jfu(xj)/πf(xj)]−11N∑iN[log(fu(zi)gu(zi))fu(zi)πr(zi)]−log(r^)
where
r^=1/n1/n∑jfu(xj)/πf(xj)∑jgu(yj)/πg(yj).(1)
is an importance sampling estimator for the ratio
cf/cg. Here you use
πf and
πg as instrumental densities for
fu and
gu respectively, and
πr to target the log ratio of unnormalized densities.
So let {xi}∼πf, {yi}∼πg, and {zi}∼πr. The numerator of (1) converges to cf. The denominator converges to cg. The ratio is consistent by the continuous mapping theorem. The log of the ratio is consistent by continuous mapping again.
Regarding the other part of the estimator,
1N∑iN[log(fu(zi)gu(zi))fu(zi)πr(zi)]→ascfE[log(fu(zi)gu(zi))]
by the law of large numbers.
My motivation is the following:
DKL(f||g)=∫∞−∞f(x)log(f(x)g(x))dx=∫∞−∞f(x){log[fu(x)gu(x)]+log[cgcf]}dx=Ef[logfu(x)gu(x)]+log[cgcf]=c−1fEπr[logfu(x)gu(x)fu(x)πr(x)]+log[cgcf].
So I just break it up into tractable pieces.
For more ideas on how to simulate the likelhood ratio, I found a paper that has a few:
https://projecteuclid.org/download/pdf_1/euclid.aos/1031594732