# Using a bounded variable within a Mixture

**URL:** <https://discourse.pymc.io/t/using-a-bounded-variable-within-a-mixture/766>\
**Category:** Questions\
**Created:** [January 20, 2018, 5:06am UTC](https://discourse.pymc.io/t/using-a-bounded-variable-within-a-mixture/766 "2018-01-20T05:06:52Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![mullachv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/mullachv/32/400_2.png) [@mullachv](https://discourse.pymc.io/u/mullachv)\
**Post date:** [January 24, 2018, 6:45pm UTC](https://discourse.pymc.io/t/using-a-bounded-variable-within-a-mixture/766/5 "2018-01-24T18:45:24Z")

</div>

@aloctavodia  
Yes, that second one works. Thank you very much.

However, how do I refer to the variable by name? So I can grab it from trace, like so trace[‘myvar’]. Here is the code in case someone else needs to use similar tricks:

```auto
with pm.Model() as model:
    alpha = pm.Gamma('alpha', 1,1)
    beta = pm.Beta('beta', 1, alpha, shape=K)
    w = pm.Deterministic('w', stick_breaking(beta))
    #a = pm.Uniform('a', 0, 50, shape=K)
    #b = pm.Uniform('b', 0, 50, shape=K)
    mu = pm.Uniform('mu', 0, 50, shape=K)
    bp = [pm.Bound(pm.Poisson, lower=1).dist( mu=mu[i]) for i in range(K)] 
    #x = pm.Mixture('obs', w, pm.Poisson.dist(mu), observed=df['x1'].values)
    x = pm.Mixture('obs', w, bp, observed=df['x1'].values)

```

---

_[View the full topic](https://discourse.pymc.io/t/using-a-bounded-variable-within-a-mixture/766)._
