# Turing.jl how to estimate param given a likelihood function

**URL:** <https://discourse.julialang.org/t/turing-jl-how-to-estimate-param-given-a-likelihood-function/115996>\
**Category:** Probabilistic Programming\
**Tags:** question, turing\
**Created:** [June 21, 2024, 10:01pm UTC](https://discourse.julialang.org/t/turing-jl-how-to-estimate-param-given-a-likelihood-function/115996 "2024-06-21T22:01:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![isaque](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/isaque/32/47634_2.png) [@isaque](https://discourse.julialang.org/u/isaque)\
**Post date:** [June 21, 2024, 10:01pm UTC](https://discourse.julialang.org/t/turing-jl-how-to-estimate-param-given-a-likelihood-function/115996/1 "2024-06-21T22:01:07Z")

</div>

I have a cost function \chi^2(p) \sim \sum\_i^{N\_\text{im}} [\beta\_i(p) - \langle \beta(p)\rangle]^2 and associated likelihood \mathscr{L}(p) \sim e^{-\chi^2/2}.

Given a parameter p, the set of \beta are calculated from a blackbox function, which involves a series of only mathematical functions.

I would like to use Julia’s Turing to maximize the likelihood function and estimate p, assuming it is drawn from a normal distribution.

I have gone through multiple tutorials and guides about Turing, yet I am pretty lost how to do this. Could anyone give me some pointers how this is done? I appreciate any help.

---

<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:** [June 22, 2024, 7:25am UTC](https://discourse.julialang.org/t/turing-jl-how-to-estimate-param-given-a-likelihood-function/115996/2 "2024-06-22T07:25:03Z")

</div>

As a probabilistic programming language, Turing is very useful to turn a model into a likelihood function and perform inference of unobserved variables. Here you already have the likelihood function and there are no unobserved variables, so I think your problem is a pure optimization problem. And more precisely a least-squares problem.  
See this post for an overview of techniques:

> [@Comparing non-linear least squares solvers](https://discourse.julialang.org/t/comparing-non-linear-least-squares-solvers/104752):
>
> I’m creating this thread as a resource for people looking to solve non-linear least squares problems in Julia, so they know what tools are available, what features they have and how well they perform. UPDATE: This comparison has been added to [juliapackagecomparisons.github.io](https://juliapackagecomparisons.github.io/pages/nonlinear_solvers/#nonlinear_least_squares_solvers) I’ll start with solvers and features. This list is simply what I found and was able to test, and my understanding of the features. [Ipopt](https://jump.dev/)[JSO](https://github.com/JuliaSmoothOptimizers)[NLLSsolver.jl](https://github.com/ojwoodford/NLLSsolver.jl)[LeastSquaresOptim.jl](https://github.com/matthieugomez/LeastSquaresOptim.jl) Registered package(s) …
