# Stochastic optimization with stan

**URL:** <https://discourse.mc-stan.org/t/stochastic-optimization-with-stan/7204>\
**Category:** General\
**Created:** [January 8, 2019, 10:51pm UTC](https://discourse.mc-stan.org/t/stochastic-optimization-with-stan/7204 "2019-01-08T22:51:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![linas](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/linas/32/5342_2.png) [@linas](https://discourse.mc-stan.org/u/linas)\
**Post date:** [January 8, 2019, 10:51pm UTC](https://discourse.mc-stan.org/t/stochastic-optimization-with-stan/7204/1 "2019-01-08T22:51:46Z")

</div>

Hi,

I am thinking to utilize the estimate of joint posterior as produced by stan to perform stochastic optimization. Basically I plan to

- estimate joint posterior theta,
- select n draws of theta: theta\_d, d = 1,…,n,
- evaluate the model at those points: y\_d = f(x, theta\_d),
- minimize expected value: min\_x sum\_{d=1}^n f(x,theta\_d)\*p(theta\_d) where p(theta\_d) is the probability of theta\_d.

p(theta\_d)=likelihood(theta\_d|data)\*prior(theta\_d). As I understand lp\_\_ at the corresponding draw d is proportional to loglikelihood(theta\_d|data).

Can anybody share any thoughts? It seems everything is very straightforward except how to chose theta\_d so the joint posterior is approximated well enough.
