# Turing model that records objective function values

**URL:** https://discourse.julialang.org/t/turing-model-that-records-objective-function-values/64167
**Category:** Probabilistic Programming
**Tags:** turing
**Created:** [July 6, 2021, 6:22pm UTC](https://discourse.julialang.org/t/turing-model-that-records-objective-function-values/64167 "2021-07-06T18:22:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![pthompson234](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pthompson234/32/24339_2.png) [@pthompson234](https://discourse.julialang.org/u/pthompson234)
#### Post date: [July 6, 2021, 6:22pm UTC](https://discourse.julialang.org/t/turing-model-that-records-objective-function-values/64167/1 "2021-07-06T18:22:17Z")

</div>

Hi, this might be a bit of a silly question but I’m using Turing to run a Bayesian MCMC algorithm. I’m using a distribution I made up as the distribution of my response variable and I would like the chain object to store the values of the PDF from this distribution. The reason for this is that the PDF takes a long time to compute so I don’t like having to compute it after the algorithm is done, since I’m effectively doing the same computation twice. Any thoughts for a workaround on this? Right now, this is what I have:

```julia
@model function turing_model(x)
    α ~ Uniform(-5.0, 5.0)
    β ~ Uniform(-5.0, 5.0)
    γ ~ Uniform(-5.0, 5.0)
    q ~ Uniform(-5.0, 5.0)

    x ~ CustomDist(α, β, γ, q)
end

```

Somewhere in there, is there a place I could record the likelihood function values for each value of the parameters? I know how to access the parameter values of each iteration from the output of the `sample` function, but it doesn’t seem to keep track of the likelihoods. Thoughts?
