# solving for unknown inside an expectation

I need to find roots for the following function:

$$f(\theta) \equiv E[R(\theta;\eta)]=0$$

for some unknown $$\theta$$ which is deterministic, while the expectation is taken over a normally distributed random variable $$\eta$$.

Consider for example that $$R(\theta;\eta) = (x+\theta(k+\eta))^{-\gamma} (k+\eta)$$, where $$x,k$$ are given numbers. So to make it simple, I essentially need to search for a $$\theta$$ such as the expectation becomes zero.

Any ideas for some algorithm?

Since you are assuming $\eta$ is normal what i would do is try to compute the expectation as fast as possible for every $\theta$. So I would compute the expectation using any numerical integration I might know. That is, if $n$ and $N$ are the Gaussian density and distribution respectively, $$f( \theta ) = \int_{ -\infty }^\infty R(\theta, \eta ) n( \eta ) d\eta = \int_0^1 R( \theta, N^{-1}(w ) ) dw\\ =\sum_{j=1}^n \int_{w_{j-1} }^{w_j} R( \theta, N^{-1}(w ) ) dw,$$ where $0=w_0 < w_1 < ....< w_n = 1$. You can use any integration tricks on each of the integrals above. For example, take $w_j = N(z_j)$ for some partition $(z_j)_{j>0 }$ of the real line, and approximate $$\int_{w_{j-1} }^{w_j} R( \theta, N^{-1}(w ) ) dw = R( \theta, N^{-1}(w_j ) )( w_j - w_{j-1} ) = R( \theta, z_j )( w_j - w_{j-1} ).$$
Once you have this step, just use any root finding method like brent's algorithm to find $\theta$. The integration needs to be fast because every step in the root finding is going to perform a new integration. Hence in your implementation you should be able to re-use parameters in the integration step, for example $z$, $w$, etc.
• i more or less get your point, but I am not sure I quite understood what you mean for "every $\theta$". In order to implement what you suggest I should know all the possible solutions of theta, is that correct?. I am not sure I quite understood that part. Commented Feb 4, 2015 at 10:04
• @user17880 - root finding methods are iterative, which means they construct a series of better and better approximations to the solution. To construct the next iteration $\theta^{k+1}$, you need (at least) to evaluate $f(\theta^k)$ (as well as possibly the derivatives $f'(\theta^k)$ and $f''(\theta^k)$, e.g., for Newton's method). Innombrabe is addressing how to do that if $f$ involves an expectation, and assumes that you'd already know how to find a root of just $R$. Commented Oct 1, 2015 at 7:46