# Is Beta(1,1) better behaved for NUTS than Uniform(0,1)?

**URL:** <https://discourse.pymc.io/t/is-beta-1-1-better-behaved-for-nuts-than-uniform-0-1/12040>\
**Category:** Questions\
**Tags:** modeling\
**Created:** [May 4, 2023, 10:57am UTC](https://discourse.pymc.io/t/is-beta-1-1-better-behaved-for-nuts-than-uniform-0-1/12040 "2023-05-04T10:57:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quantumstrider](https://avatars.discourse-cdn.com/v4/letter/q/edb3f5/32.png) [@quantumstrider](https://discourse.pymc.io/u/quantumstrider)\
**Post date:** [May 4, 2023, 10:57am UTC](https://discourse.pymc.io/t/is-beta-1-1-better-behaved-for-nuts-than-uniform-0-1/12040/1 "2023-05-04T10:57:43Z")

</div>

I’ve read on here that in general using truncated distributions is not good for NUTS since it can run into divergences at the boundaries. If I have MvNormal mean parameters that I want to fit and which have to be between 0-1, would using Beta(1,1) as my uniform prior over 0-1 be better behaved than Uniform(0,1) directly? In practice the true values of my mean parameters for mock tests are not usually near the boundaries 0 and 1 and both Beta and Uniform are converging to the correct truth – but I have some divergences. I just started runs upping target\_accept from the default 0.8 to 0.9 to encourage smaller adaptive step sizes and more thorough exploration.

---

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [May 4, 2023, 11:28am UTC](https://discourse.pymc.io/t/is-beta-1-1-better-behaved-for-nuts-than-uniform-0-1/12040/2 "2023-05-04T11:28:24Z")

</div>

Uniform(0, 1) and Beta(1, 1) are exactly the same thing for NUTS. The boundary problem is not an issue because we automatically transform the variables so that proposals can be done on an unconstrained space by NUTS (unless you disabled transforms manually).

---

<div class="post-metadata">

**Author:** ![quantumstrider](https://avatars.discourse-cdn.com/v4/letter/q/edb3f5/32.png) [@quantumstrider](https://discourse.pymc.io/u/quantumstrider)\
**Post date:** [May 4, 2023, 11:32am UTC](https://discourse.pymc.io/t/is-beta-1-1-better-behaved-for-nuts-than-uniform-0-1/12040/3 "2023-05-04T11:32:24Z")

</div>

Thanks @ricardoV94 ! Is there a pedagogical reference / explanation for how you transform the variables to an unconstrained space and what that actually means?

---

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [May 4, 2023, 11:36am UTC](https://discourse.pymc.io/t/is-beta-1-1-better-behaved-for-nuts-than-uniform-0-1/12040/4 "2023-05-04T11:36:26Z")

</div>

Maybe the STAN manual is a good guide:

> **[8.5 Program block: parameters | Stan Reference Manual](https://mc-stan.org/docs/reference-manual/program-block-parameters.html#constraining-inverse-transform)**
>
> Stan reference manual specifying the syntax and semantics of the Stan programming language.

> **[10 Constraint Transforms | Stan Reference Manual](https://mc-stan.org/docs/reference-manual/variable-transforms.html)**
>
> Stan reference manual specifying the syntax and semantics of the Stan programming language.

Everything they say applies to PyMC NUTS sampler
