Numerically solving equations with expectations

183 Views Asked by At

I have a equation $\mathbb{E}_\theta f(x,\theta)=a$, where $\theta$ is a vector real random variable with a known distribution, $a$ is a real constant, $x$ is a real (can be vector valued) variable. The function $f$ is too complex in $\theta$ for me to find a closed form expectation thus removing $\theta$.

One way to solve this is to set a value to $x$ and compute expectation using monte-carlo method and then increment or decrement $x$ and redo... I know that the function $f$ is monotonic in $x$ so the above method works. Is there some other, possibly easier way to solve it numerically? I am using Matlab and it would be great if there is existing function that I can use where I input $f$ and CDF of $\theta$ and it outputs solution.

1

There are 1 best solutions below

0
On

Monte-Carlo functions are quite easy to create, I don't think some special-made function will help you out too much. Thus, similar to what was suggested, what you can to do is create a function that takes x as an input and performs the numerical integration. Call this function $exp\_mean(x)$.

$exp\_mean(x)=E_{\theta}[f(x,\theta)] - a$

(Hint: If possible, take the draws outside of the function so that you do not need to re-draw values every time the function is called). Then, use one of the non-linear solvers to solve for x such as fsolve.

x = fsolve('exp_mean',x0)

where x0 is some starting value. Try experimenting with different values for the number of draws and starting values. (I always prefer to do a grid search to obtain starting values).