# your codeDiscretization, Integration and Interpolation
Expected Utility of Consumption
Assume consumption is given by \(C(\epsilon)=(\exp({\epsilon}))\) with \(\epsilon\) is a random variable with standard deviation \({\sigma}_{\epsilon}=0.05\).
Set utility of consumption to be: \(U(x)=\frac{x^{-\gamma}}{-\gamma}\).
Goal is to compare several ways to compute \(E_{\epsilon}(U(C(\epsilon)))\) .
We’ll use the calibration \(\gamma=40\) and \({\sigma}_{\epsilon}=0.05\).
(optional) Compute the result in closed form
Hint: \[\int_{-\infty}^{\infty}e^{-(a x^2+bx +c)} dx = \sqrt{\frac{\pi}{a}} e^{\frac{b^2}{4a}+c}\]
Compute the result using Monte-Carlo simulations. Evaluate the variance of the estimation.
# your codeCompute the result using Gauss-Hermite quadrature
# your codeInterpolation Methods
Take
\[ f(x)=\frac{1}{1+25x^2}, \quad x\in[-1,1] \]
and compare several interpolation methods.
- Implement piecewise linear interpolation on an equally spaced grid.
# your code- Compute interpolation errors (max error and RMSE) on a fine grid.
# your codePlot
Compare with:
- nearest-neighbor interpolation on the same nodes
- natural cubic spline interpolation on the same nodes
- global polynomial interpolation on Chebyshev nodes
# your code- Repeat for \(N=9\) and \(N=21\).
# your code- Comments
# your code