# Inverse problem with Stan

**URL:** <https://discourse.mc-stan.org/t/inverse-problem-with-stan/1293>\
**Category:** Algorithms\
**Tags:** optimization\
**Created:** [July 19, 2017, 8:46pm UTC](https://discourse.mc-stan.org/t/inverse-problem-with-stan/1293 "2017-07-19T20:46:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ishihama](https://avatars.discourse-cdn.com/v4/letter/i/90db22/32.png) [@ishihama](https://discourse.mc-stan.org/u/ishihama)\
**Post date:** [July 19, 2017, 8:46pm UTC](https://discourse.mc-stan.org/t/inverse-problem-with-stan/1293/1 "2017-07-19T20:46:30Z")

</div>

I am facing an inverse problem with two input variables and two  
output variables. I think it is well posed problem.

I am looking for STAN modeling example to attack this problem  
instead of using so-called Newton algorithm.

Do you know about a package appropriate for this purpose?

Concerning the conjugacies of prior distribution and posterior distribution

By using conjugation, I think one can derive an approximate solution of the inverse problem.

Do you know about an example to analytically solve  
this based on Bayesian statistics?

Thx in advance,

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [July 22, 2017, 12:05am UTC](https://discourse.mc-stan.org/t/inverse-problem-with-stan/1293/2 "2017-07-22T00:05:57Z")

</div>

If by “inverse problem” you mean calculating the Bayesian posterior, then yes, Stan can do that. The manual’s full of examples, but you should start with whatever interface you want to use.

Or you can use L-BFGS (way better than the Newton algorithm in practice) to do optimization in Stan.

---

<div class="post-metadata">

**Author:** ![ishihama](https://avatars.discourse-cdn.com/v4/letter/i/90db22/32.png) [@ishihama](https://discourse.mc-stan.org/u/ishihama)\
**Post date:** [July 27, 2017, 3:25am UTC](https://discourse.mc-stan.org/t/inverse-problem-with-stan/1293/3 "2017-07-27T03:25:33Z")

</div>

Thanks very much, Bob.  
I have recently found “particle sworm optimization”.  
I will compare this with an approach with Bayesian posterior calculation.

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [July 27, 2017, 2:57pm UTC](https://discourse.mc-stan.org/t/inverse-problem-with-stan/1293/4 "2017-07-27T14:57:50Z")

</div>

That’s like comparing apples and organges. Bayesian posteriors don’t give you max likelihood esitmates. You can compare it with our optimization. What you’ll find is that particle methods without gradients tend not to scale well with dimensionality, either for optimization or sampling. There is a _huge_ amount of material on this in the optimzation literature, but a bit less so in the MCMC literature, where particle methods have resurged in popularlity despite not scaling well with dimensionality in most circumstances.
