# Doubt in Gaussian Mixture Model notebook in docs

**URL:** <https://discourse.pymc.io/t/doubt-in-gaussian-mixture-model-notebook-in-docs/689>\
**Category:** Questions\
**Tags:** doc\
**Created:** [December 30, 2017, 9:55pm UTC](https://discourse.pymc.io/t/doubt-in-gaussian-mixture-model-notebook-in-docs/689 "2017-12-30T21:55:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vaibhavdixit02](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/vaibhavdixit02/32/383_2.png) [@Vaibhavdixit02](https://discourse.pymc.io/u/Vaibhavdixit02)\
**Post date:** [December 30, 2017, 9:55pm UTC](https://discourse.pymc.io/t/doubt-in-gaussian-mixture-model-notebook-in-docs/689/1 "2017-12-30T21:55:32Z")

</div>

I am stuck at [http://docs.pymc.io/notebooks/gaussian\_mixture\_model.html](http://docs.pymc.io/notebooks/gaussian_mixture_model.html), the part where we use pm.Potential in setting up the model, I am unable to understand it’s necessity in the example, also how does p\_min\_potential or order\_means\_potential affect the distribution of p or means. Any help would be much appreciated!

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [December 31, 2017, 10:38am UTC](https://discourse.pymc.io/t/doubt-in-gaussian-mixture-model-notebook-in-docs/689/2 "2017-12-31T10:38:01Z")

</div>

`pm.Potential()` is additional terms you add to the final model logp, usually we use it to put additional constrain to the log-likelihood. I think the key is first understand how potential works.  
For example, say you are trying to model a parameter x, but instead of what we usually do by putting a prior on the parameter: x~dist, you can put a flat prior on x, but add the prior information using potential.  
Notice that doing so from the perspective of model logp is the same, as `logp = logp param given prior + logp evidence given param`.

Now, say you use MH to sample, then at each t you propose a value (sample) and accept or reject by compare with the previous sample. This is the foundation of how we can use potential to add constrains to the model, which is what you see in the example above. For example, say you want to model x1 and x2 with x1 \< x2 (ie they are ordered). You can add a potential to the model so that whenever x1 \> x2, the model logp goes to -inf. In another word, whenever the proposal value x1\_p, x2\_p that x1\_p \> x2\_p, the logp becomes -inf and the proposal will be rejected, resulting the desired constrains we put on x1 and x2.

---

<div class="post-metadata">

**Author:** ![Vaibhavdixit02](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/vaibhavdixit02/32/383_2.png) [@Vaibhavdixit02](https://discourse.pymc.io/u/Vaibhavdixit02)\
**Post date:** [December 31, 2017, 11:01am UTC](https://discourse.pymc.io/t/doubt-in-gaussian-mixture-model-notebook-in-docs/689/3 "2017-12-31T11:01:21Z")

</div>

Thank you! This clears it up 😃
