# Why is the Marginal Likelihood Estimator proposed in VAE not based on importance sampling?

I'm interested in evaluating $$p(x)$$ using a variational autoencoder. I would expect the straightforward way to estimate the marginal likelihood to be based on importance sampling:

\begin{align} p(x) &= \int_z p(z) p(x|z) \frac{q(z|x)}{q(z|x)} dz \\ & = \mathbb{E}_{q(z|x)} [ p(x | z) \frac{p(z)}{q(z|x)} ] \end{align}

However,

1. in Kingma and Welling (2013), the authors suggest a different method in appendix D. Is there a good reason for this?

2. The authors furthermore suggest to estimate $$q(z|x)$$ with a density estimation after drawing samples from it. Why is this necessary if we know $$q(z|x)$$ explicitly?

• Why should the estimator be based on importance sampling, though? Apr 16 at 13:39
• @Xi'an apologies, I added the reference
– Lisa
Apr 16 at 14:27
• @AryaMcCarthy I'm still working on my understanding there, but it seemed intuitive given that the ELBO can be obtained directly through importance sampling. Can you explain the what might speak for or against the different estimators?
– Lisa
Apr 16 at 14:34
• Importance sampling can give poor estimates—there may be high variability in the importance weights; samples from $q_\phi$ may not fully cover $p_\theta$. They used Hamiltonian Monte Carlo to draw samples from the true posterior instead of the approximate one. From there, it looks like they used a tweaked version of the harmonic mean estimator that gets constantly criticized for working poorly, but keeps getting used because it's easy to code. Dunno whether using $q$ improved it. Apr 17 at 5:30