# Using Turing as a replacement of Klara

**URL:** <https://discourse.julialang.org/t/using-turing-as-a-replacement-of-klara/32152>\
**Category:** General Usage\
**Created:** [December 11, 2019, 2:39pm UTC](https://discourse.julialang.org/t/using-turing-as-a-replacement-of-klara/32152 "2019-12-11T14:39:02Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![cpfiffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cpfiffer/32/208747_2.png) [@cpfiffer](https://discourse.julialang.org/u/cpfiffer)\
**Post date:** [January 14, 2020, 5:26pm UTC](https://discourse.julialang.org/t/using-turing-as-a-replacement-of-klara/32152/21 "2020-01-14T17:26:37Z")

</div>

`data` is that data you have observed. I’m not familiar with your problem so I can’t tell you exactly what it is.

---

<div class="post-metadata">

**Author:** ![robsmith11](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robsmith11/32/29641_2.png) [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Post date:** [January 14, 2020, 6:40pm UTC](https://discourse.julialang.org/t/using-turing-as-a-replacement-of-klara/32152/22 "2020-01-14T18:40:52Z")

</div>

> Turing is for much more complex models where you can’t or don’t want to write up the likelihood.

Sorry for getting a bit off-topic, but I was intrigued by your comment. I guess I don’t understand Turing fully. What is an example of a model that can be used by Turing but it’s likelihood can’t be written?

---

<div class="post-metadata">

**Author:** ![cpfiffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cpfiffer/32/208747_2.png) [@cpfiffer](https://discourse.julialang.org/u/cpfiffer)\
**Post date:** [January 14, 2020, 8:22pm UTC](https://discourse.julialang.org/t/using-turing-as-a-replacement-of-klara/32152/23 "2020-01-14T20:22:40Z")

</div>

I use “can’t” here to refer to the case where it’s just time intensive to do so. Turing kind of implicitly builds a likelihood function that is quite ugly in its raw form. Models with a lot of hierarchy, many different distribution types, and stochastic control flow would be cases where an analytic or numerical likelihood are very difficult to write down by hand.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 15, 2020, 8:41am UTC](https://discourse.julialang.org/t/using-turing-as-a-replacement-of-klara/32152/24 "2020-01-15T08:41:01Z")

</div>

> [@robsmith11](#):
>
> What is an example of a model that can be used by Turing but it’s likelihood can’t be written?

I don’t believe that such models exist, it is rather a preference that some people have.

I always prefer to code the likelihood directly. Doing so allows me to utilitise standard tools for benchmarking, testing, and optimizing my code. This was the motivation for writing

> **[GitHub - tpapp/DynamicHMC.jl: Implementation of robust dynamic Hamiltonian...](https://github.com/tpapp/DynamicHMC.jl)**
>
> Implementation of robust dynamic Hamiltonian Monte Carlo methods (NUTS) in Julia. - GitHub - tpapp/DynamicHMC.jl: Implementation of robust dynamic Hamiltonian Monte Carlo methods (NUTS) in Julia.

If you are otherwise comfortable coding log posteriors, you may find it useful.

---

<div class="post-metadata">

**Author:** ![robsmith11](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robsmith11/32/29641_2.png) [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Post date:** [January 15, 2020, 10:03am UTC](https://discourse.julialang.org/t/using-turing-as-a-replacement-of-klara/32152/25 "2020-01-15T10:03:10Z")

</div>

Thanks. I too prefer using explicit likelihoods for the reasons you mentioned, which is why I am already using your excellent DynamicHMC.

I’m still relatively new to probabilistic programming, so wanted to check that I wasn’t missing out on the ability to use a broad class of models by not using Turing.

---

<div class="post-metadata">

**Author:** ![marouane1994](https://avatars.discourse-cdn.com/v4/letter/m/74df32/32.png) [@marouane1994](https://discourse.julialang.org/u/marouane1994)\
**Post date:** [January 17, 2020, 9:16am UTC](https://discourse.julialang.org/t/using-turing-as-a-replacement-of-klara/32152/26 "2020-01-17T09:16:46Z")

</div>

so `data`is the generated values from the posterior that we have right?

---

<div class="post-metadata">

**Author:** ![cpfiffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cpfiffer/32/208747_2.png) [@cpfiffer](https://discourse.julialang.org/u/cpfiffer)\
**Post date:** [January 17, 2020, 3:14pm UTC](https://discourse.julialang.org/t/using-turing-as-a-replacement-of-klara/32152/27 "2020-01-17T15:14:16Z")

</div>

Yes. `data` is the data you are conditioning on when you calculate the posterior `p(parameters | data)`.

[Previous page](https://discourse.julialang.org/t/using-turing-as-a-replacement-of-klara/32152.md?page=1)
