# Some confusion about inferring local latent variables from local data

**URL:** <https://discourse.edwardlib.org/t/some-confusion-about-inferring-local-latent-variables-from-local-data/63>\
**Category:** General\
**Created:** [March 30, 2017, 12:24pm UTC](https://discourse.edwardlib.org/t/some-confusion-about-inferring-local-latent-variables-from-local-data/63 "2017-03-30T12:24:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yc14600](https://avatars.discourse-cdn.com/v4/letter/y/9f8e36/32.png) [@yc14600](https://discourse.edwardlib.org/u/yc14600)\
**Post date:** [March 30, 2017, 12:24pm UTC](https://discourse.edwardlib.org/t/some-confusion-about-inferring-local-latent-variables-from-local-data/63/1 "2017-03-30T12:24:01Z")

</div>

Hi Dustin

I have some confusion about inferring local latent variables by Edward inference, say we have different local latent variables z\_n for different groups of datapoints x\_n, and all z\_n share the same prior distribution with a global latent variable \beta, if I input all datapoints into Inference({z:qz, \beta: q\beta},{x:x\_data}), can z\_n be updated accordingly by x\_n? Or do I need to create different inference for each z\_n? I think it should be the former case, but I’m not familiar with tensorflow and didn’t find related documentation.  
Sorry to bother you, thanks in advance for your help~!

---

<div class="post-metadata">

**Author:** ![dustin](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/dustin/32/134_2.png) [@dustin](https://discourse.edwardlib.org/u/dustin)\
**Post date:** [March 30, 2017, 1:56pm UTC](https://discourse.edwardlib.org/t/some-confusion-about-inferring-local-latent-variables-from-local-data/63/2 "2017-03-30T13:56:25Z")

</div>

Thanks for asking.

The semantics of `Inference({z: qz, beta: qbeta}, {x: x_data})` is understood verbatim as “infer the distribution p(z, beta | x = x\_data) using the approximating distribution q(z, beta)”. This holds irregardless of where certain latent variables are local or global. Or to answer the question more directly, if you input all data points x\_n into inference, all z\_n’s will be updated.

How inference updates latent variables depends on the choice of algorithm. For example, if you only want to update a subset of local variables at a time according to minibatches of data, see Edward’s [data subsampling guide](http://edwardlib.org/api/inference-data-subsampling).

---

<div class="post-metadata">

**Author:** ![yc14600](https://avatars.discourse-cdn.com/v4/letter/y/9f8e36/32.png) [@yc14600](https://discourse.edwardlib.org/u/yc14600)\
**Post date:** [March 30, 2017, 2:18pm UTC](https://discourse.edwardlib.org/t/some-confusion-about-inferring-local-latent-variables-from-local-data/63/3 "2017-03-30T14:18:19Z")

</div>

That’s very helpful, thank you very much!
