# Automatic transformation of constrained distributions in Turing.jl

**URL:** <https://discourse.julialang.org/t/automatic-transformation-of-constrained-distributions-in-turing-jl/100369>\
**Category:** General Usage\
**Tags:** question, turing\
**Created:** [June 14, 2023, 9:53pm UTC](https://discourse.julialang.org/t/automatic-transformation-of-constrained-distributions-in-turing-jl/100369 "2023-06-14T21:53:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandy6502](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sandy6502/32/50764_2.png) [@sandy6502](https://discourse.julialang.org/u/sandy6502)\
**Post date:** [June 14, 2023, 9:53pm UTC](https://discourse.julialang.org/t/automatic-transformation-of-constrained-distributions-in-turing-jl/100369/1 "2023-06-14T21:53:11Z")

</div>

This is a question about automatic transformation of constrained distributions.

The [docs on compiler design](https://turinglang.org/v0.25/docs/for-developers/compiler) say “Random variables whose distributions have a constrained support are transformed using a bijector from Bijectors.jl so that the sampling happens in the unconstrained space.”

Suppose the following model:

```julia
@model function gdemo(x, y)
    s² ~ InverseGamma(2, 3)
    mu ~ Uniform(0, 1)
    x ~ Normal(mu, sqrt(s²))
    return y ~ Normal(mu, sqrt(s²))
end

```

Questions:

- If I use an HMC sampler (e.g. NUTS), do I need to manually transform the distribution of mu or can I rely on Turing.jl to do this for me?
- If I can, how can I find out the details of the transformation?
- When I look at my samples in the returned chain, will they be in the unconstrained space or will they be in the original constrained space?

Thank you!
