Closed shenkev closed 6 years ago
Are we getting only 1 monte carlo sample per update() call? Do we need to worry about burn-in here? Shouldn't n_iter be greater than number of empirical samples in this case?
Yes. Yes. No. Burn-in is just an argument to throw away initial samples at the start of the Markov chain. In practice, you set the number of Empirical samples to be, say, twice as large as you want and take only the second half. An MCMC example with burn-in is examples/bayesian_linear_regression.py
.
Ah I see, so to "take only the second half," we do something like:
qz_kept = qz.params[to_keep_index:]?
the _sample_n(self, n, seed=None) function doesn't seem to have an argument to keep only the later samples
edit: ah ok you can wrap it in a variable: Empirical(qz.params[to_keep_index:])
Sorry in advance if I have a conceptual misunderstanding but I'm wondering why in monte_carlo.py the variable n_iter is being set to the number of empirical samples (call this T) in the posterior. Relevant line:
kwargs['n_iter'] = np.amin([qz.params.shape.as_list()[0]
From the docs, n_iter is "if controlling inference manually, it is the expected number of calls to
update()
". Are we getting only 1 monte carlo sample per update() call? Do we need to worry about burn-in here? Shouldn't n_iter be greater than number of empirical samples in this case?The doc says:
how would you do this?
I tried calling inference.update() for x > T number of times
and I get an out of index error (here T=1000, x=1001).
I think this suggests monte_carlo.py class is initialized to expect T calls to update() and calling update() more than T times messes with the implementation? How would you burn in/keep every m samples?
Relevant code in monte_carlo.py: