Stochastic optimization with stan



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.