# Constrain one variable to be greater than another

**URL:** <https://discourse.pymc.io/t/constrain-one-variable-to-be-greater-than-another/792>\
**Category:** Questions\
**Created:** [January 28, 2018, 11:57am UTC](https://discourse.pymc.io/t/constrain-one-variable-to-be-greater-than-another/792 "2018-01-28T11:57:37Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [January 28, 2018, 1:02pm UTC](https://discourse.pymc.io/t/constrain-one-variable-to-be-greater-than-another/792/2 "2018-01-28T13:02:00Z")

</div>

Yes, you are seeing label switching in your trace. It happens a lot with mixture models.  
One of the must-reads related to this topic is Michael Betancourt’s Stan case study [Identifying Bayesian Mixture Models](http://mc-stan.org/users/documentation/case-studies/identifying_mixture_models.html). I have a [Gist here](https://gist.github.com/junpenglao/4d65d1a9bf80e8d371446fadda9deb7a) replicating all the experiment in PyMC3.

As an experiment, you can also switch the trace by hand. We have a discussion here in [this post](https://discourse.pymc.io/t/gaussian-mixture-of-regression/537), with [code here](https://gist.github.com/junpenglao/1907bf019906c125f63126ec4bf23880).

Something related is if you are sampling an Ordered and bounded vector (e.g., x1 \< x2 ~ Uniform), current implementation seems to be biased ([Sampling uniformly in a triangular support](https://discourse.pymc.io/t/sampling-uniformly-in-a-triangular-support/765)). But for continous RV it should be fine.

---

_[View the full topic](https://discourse.pymc.io/t/constrain-one-variable-to-be-greater-than-another/792)._
