# Boundary for Turing parameters

**URL:** <https://discourse.julialang.org/t/boundary-for-turing-parameters/129290>\
**Category:** General Usage\
**Tags:** question, turing\
**Created:** [May 24, 2025, 7:52am UTC](https://discourse.julialang.org/t/boundary-for-turing-parameters/129290 "2025-05-24T07:52:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cyan](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Cyan](https://discourse.julialang.org/u/Cyan)\
**Post date:** [May 24, 2025, 7:52am UTC](https://discourse.julialang.org/t/boundary-for-turing-parameters/129290/1 "2025-05-24T07:52:26Z")

</div>

I set my priors for parameters like this,

```julia
    b ~ Normal(1.5, 1.)
    s ~ Normal(0.1, 1)
    q ~ Normal(0.7, 1.0)

```

But I want to set strong limitation for these parameters, such as

```julia
abs(b)<10
abs(q)<1
0<abs(s)<1

```

How can I make it?

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [May 24, 2025, 8:56am UTC](https://discourse.julialang.org/t/boundary-for-turing-parameters/129290/2 "2025-05-24T08:56:21Z")

</div>

Maybe something like [GitHub - tpapp/TransformVariables.jl: Transformations to contrained variables from ℝⁿ.](https://github.com/tpapp/TransformVariables.jl) ?

---

<div class="post-metadata">

**Author:** ![simonsteiger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonsteiger/32/209862_2.png) [@simonsteiger](https://discourse.julialang.org/u/simonsteiger)\
**Post date:** [May 24, 2025, 8:59am UTC](https://discourse.julialang.org/t/boundary-for-turing-parameters/129290/3 "2025-05-24T08:59:46Z")

</div>

Hi there!

Another way to constrain parameters in Turing would be to truncate their distributions using `truncated`:

```julia
sigma ~ truncated(Normal(0, 1), lower=0)

```

---

<div class="post-metadata">

**Author:** ![eteppo](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@eteppo](https://discourse.julialang.org/u/eteppo)\
**Post date:** [May 24, 2025, 9:20am UTC](https://discourse.julialang.org/t/boundary-for-turing-parameters/129290/4 "2025-05-24T09:20:53Z")

</div>

I think you can use the `truncated` function (defined in [Distributions.jl](https://juliastats.org/Distributions.jl/stable/truncate/#Distributions.truncated)) on the distribution and the keyword arguments `lower`and `upper` like this

```julia
    b ~ truncated(Normal(1.5, 1.0); lower = -10, upper = 10)
    s ~ truncated(Normal(0.1, 1.0); lower = -1, upper = 1)
    q ~ truncated(Normal(0.7, 1.0); lower = -1, upper = 1)

```

This means it’s physically/mathematically impossible for the parameters to be outside the intervals (prior assumption/knowledge).

---

<div class="post-metadata">

**Author:** ![VinceNeede](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vinceneede/32/215744_2.png) [@VinceNeede](https://discourse.julialang.org/u/VinceNeede)\
**Post date:** [May 24, 2025, 9:31am UTC](https://discourse.julialang.org/t/boundary-for-turing-parameters/129290/5 "2025-05-24T09:31:28Z")

</div>

Just wanted to add the ref to documentation:

> **[Truncated Distributions · Distributions.jl](https://juliastats.org/Distributions.jl/stable/truncate/#Distributions.truncated)**
>
> Documentation for Distributions.jl.

---

<div class="post-metadata">

**Author:** ![ForceBru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/forcebru/32/21389_2.png) [@ForceBru](https://discourse.julialang.org/u/ForceBru)\
**Post date:** [May 24, 2025, 7:29pm UTC](https://discourse.julialang.org/t/boundary-for-turing-parameters/129290/6 "2025-05-24T19:29:03Z")

</div>

Since all your constraints are of the form `abs(x) < y`, which is the same as `-y < x < y`, the simplest approach is to use a uniform distribution: `x ~ Uniform(-y, y)`.
