Would trace = approx.sample(100) return exactly the values of those particles that I have trained?

No it will sample from particles uniformly

But what mout1 = approx.sample_node(out, 10000).mean() is doing?

It samples from the empirical distribution and makes appropriate replacements in the graph. So every Distribution node is replaced with it’s posterior distribution (symbolically).

I want to average the prediction made by the particles(models)

This was not implemented. Now I see that it might be useful to integrate over the posterior. The way you can integrate over the posterior looks like

```
# based mostly on https://github.com/pymc-devs/pymc3/blob/master/pymc3/variational/opvi.py#L1098
# or https://github.com/pymc-devs/pymc3/blob/master/pymc3/variational/opvi.py#L1470
def integrate_over_histogram(approx, node):
if not isinstance(approx, pm.Empirical):
raise ValueError('You need empirical distribution here, got {}'.format(type(approx)))
node = approx.to_flat_input(node)
def sample(post):
return theano.clone(node, {approx.input: post})
nodes, _ = theano.scan(sample, approx.histogram)
return nodes
# given the notebook above
Esin = integrate_over_histogram(approx, out).mean()
```