# Question regarding inference API

**URL:** <https://discourse.edwardlib.org/t/question-regarding-inference-api/129>\
**Category:** General\
**Created:** [May 14, 2017, 11:09pm UTC](https://discourse.edwardlib.org/t/question-regarding-inference-api/129 "2017-05-14T23:09:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shansfolder](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/shansfolder/32/34_2.png) [@shansfolder](https://discourse.edwardlib.org/u/shansfolder)\
**Post date:** [May 14, 2017, 11:09pm UTC](https://discourse.edwardlib.org/t/question-regarding-inference-api/129/1 "2017-05-14T23:09:24Z")

</div>

Hi, thank you for the work of this great package! I have a question regarding inference API.

According to the [inference tutorial](http://edwardlib.org/api/inference), inference API is as simple as running one method:  
`inference = ed.Inference({z: qz, beta: qbeta}, {x: x_train})`

To my knowledge, to optimize ELBO, variational inference requires defining the family of variational distribution **q(z; lambda)** and joint likelihood **p(x, z; theta)**. Does Edward assumes implicitly that both are normal distribution? If so, can we override the assumption and pass for example a non-Gaussian joint likelihood function **p(x, z; theta)** instead?

Thanks,  
Shan

---

<div class="post-metadata">

**Author:** ![shansfolder](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/shansfolder/32/34_2.png) [@shansfolder](https://discourse.edwardlib.org/u/shansfolder)\
**Post date:** [May 15, 2017, 12:45pm UTC](https://discourse.edwardlib.org/t/question-regarding-inference-api/129/2 "2017-05-15T12:45:51Z")

</div>

I figured out that the variable `qz` and `qbeta` defines the variational distribution 🙂 but I am still puzzled about how to set p(x, z) or p(x|z)? thanks

---

<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:** [May 15, 2017, 5:38pm UTC](https://discourse.edwardlib.org/t/question-regarding-inference-api/129/3 "2017-05-15T17:38:35Z")

</div>

In English, that inference line says, “Infer z (using qz) and beta (using qbeta) given that we observe x = x\_train”. In math, this is `q(z, beta; parameters) \approx p(z, beta | x = x_train)`. The collection of model variables `x`, `z`, `beta` define your joint distribution.

---

<div class="post-metadata">

**Author:** ![shansfolder](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/shansfolder/32/34_2.png) [@shansfolder](https://discourse.edwardlib.org/u/shansfolder)\
**Post date:** [May 15, 2017, 9:18pm UTC](https://discourse.edwardlib.org/t/question-regarding-inference-api/129/4 "2017-05-15T21:18:15Z")

</div>

Ah got it! thanks!

The point that initially got me confused is that I thought x, z are method argument names. As I was reading the inference documentation first, there is no context of them. I don’t know if it make sense to give a complete example in [inference API doc](http://edwardlib.org/api/inference), from defining x, z, beta, qz, qbeta to the inference line, although this concept will become clear when the user read other documentations. but thanks dustin!
