# Bound of a sum of variables

**URL:** <https://discourse.pymc.io/t/bound-of-a-sum-of-variables/2143>\
**Category:** Questions\
**Created:** [November 4, 2018, 8:00pm UTC](https://discourse.pymc.io/t/bound-of-a-sum-of-variables/2143 "2018-11-04T20:00:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanWeitzenfeld](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/danweitzenfeld/32/30_2.png) [@DanWeitzenfeld](https://discourse.pymc.io/u/DanWeitzenfeld)\
**Post date:** [November 4, 2018, 8:00pm UTC](https://discourse.pymc.io/t/bound-of-a-sum-of-variables/2143/1 "2018-11-04T20:00:19Z")

</div>

If I want to set a bound on a sum of variables, is my best bet to use `pm.Potential`?

In [this example](https://gist.github.com/DanielWeitzenfeld/ca97819cf8341c3812b9f8f55c324b45), adding a pm.Potential makes one of the chains go haywire. I suspect, though, it’s because I’ve set the sum of the true values to be very close to the point where the potential “kicks in,” because when I set the threshold so high as to be irrelevant, the problem goes away.

Should I try a smoother function for my bound so it’s not a step function? Any other best practices for this?  
Thanks in advance.

---

<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:** [November 4, 2018, 8:29pm UTC](https://discourse.pymc.io/t/bound-of-a-sum-of-variables/2143/2 "2018-11-04T20:29:12Z")

</div>

I think a harder bound condition should help: `bound = pm.Potential('bound', T.switch(T.gt(rho[0] + rho[1], 1.0), -np.inf, 0.0))`  
However, you might still have divergent issue tho, as samples could goes out of bound.
