# Finding optimal drift, importance sampling, least square monte carlo

I am working with Importance sampling for Least Squared monte carlo and have now problems understanding the implementation of the Robbins-Monro algorithm for finding the optimal drift for finding minimum variance of my estimate. The original problem formulation that is now answered is given here.

The article I am following for Robbins-Monro algorithm is this link

The problem i want to solve is to find a optimal drift $\theta^*$ by solving:

$H(\theta^*)=\min_{\theta}H(\theta)$

Where $H(\theta)=\mathbb{E}\left[ G^2(Z)e^{-\theta Z+\frac{1}{2}\theta^2}\right]$, the second moment of the payoff function $G(Z)=\max(K-S(t),0)$. Indeed, we have: $\nabla H(\theta)=0$

Now following the Morris monro algorithm in the link, the general formulation of the stochastic algorithm is given in equation (10) and is given by:

$X_{n+1}=X_n-\gamma_{n+1}F(X_n,Z_{n+1})$

and going further to equation (15) we have the second moment (the gradient of $H(\theta)$) given by:

$h(\theta)=\nabla H(\theta)=\mathbb{E}\left[(\theta-Z)G^2(Z)e^{-\theta Z+\frac{1}{2}\theta^2}\right]$.

Now I wonder, since I don't know the second moment, how should I approximate it numerically in order to evaluate the algorithm? Given in the article, they don't really explain how the second moment is found?

Appreciate for help. Thank you!

$h(\theta)=\nabla H(\theta)=\mathbb{E}\left[(\theta-Z)G^2(Z)e^{-\theta Z+\frac{1}{2}\theta^2}\right]$
so just take a bunch of paths and evaluate $$(\theta-Z)G^2(Z)e^{-\theta Z+\frac{1}{2}\theta^2}$$on them and take the average.