# Turing sampling from priors

**URL:** <https://discourse.julialang.org/t/turing-sampling-from-priors/81486>\
**Category:** New to Julia\
**Tags:** turing\
**Created:** [May 23, 2022, 5:02am UTC](https://discourse.julialang.org/t/turing-sampling-from-priors/81486 "2022-05-23T05:02:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aminath\_Shausan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aminath_shausan/32/33587_2.png) [@Aminath\_Shausan](https://discourse.julialang.org/u/Aminath_Shausan)\
**Post date:** [May 23, 2022, 5:02am UTC](https://discourse.julialang.org/t/turing-sampling-from-priors/81486/1 "2022-05-23T05:02:38Z")

</div>

Hi,

I am migrating to Turing.jl from Stan. I am trying to understand the coding of this [example](https://turing.ml/stable/tutorials/07-poisson-regression/), and was wondering if there is a way to generate samples from priors? Also, is there a way to include a generated quantities block (or function), similar to Stan, where we can use the posterior to compute various quantities of interest?

```julia
# Bayesian poisson regression (LR)
@model function poisson_regression(x, y, n, σ²)
    b0 ~ Normal(0, σ²)
    b1 ~ Normal(0, σ²)
    b2 ~ Normal(0, σ²)
    b3 ~ Normal(0, σ²)
    for i in 1:n
        theta = b0 + b1 * x[i, 1] + b2 * x[i, 2] + b3 * x[i, 3]
        y[i] ~ Poisson(exp(theta))
    end
end;

```

Thanks

---

<div class="post-metadata">

**Author:** ![wc4wc4wc4](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wc4wc4wc4/32/23038_2.png) [@wc4wc4wc4](https://discourse.julialang.org/u/wc4wc4wc4)\
**Post date:** [May 23, 2022, 6:26am UTC](https://discourse.julialang.org/t/turing-sampling-from-priors/81486/2 "2022-05-23T06:26:12Z")

</div>

Regarding priors, see [this](https://storopoli.github.io/Bayesian-Julia/pages/4_Turing/#prior_and_posterior_predictive_checks).

Regarding generated quantities, you can see the code that I’m using [here](https://discourse.julialang.org/t/easier-use-of-generated-quantities/81305).  
We are working making it easier to do so.

I hope this helps!
