Hi I have problem with calculating this expected utility with means of numerical integration, using matlab. The matrix stock data is a 1000x8 matrix with columns representing 7 stocks (columns 2-8, where the first column is the date of the measurments) I want first to calculate the integral for column 2. (The rest I can do by myself). The problem is that I get an expected utility in the order of -1.6524e-22, which is way wrong. It should be something like 1.0e-4.
Thanks in advance in any help in doing this.
The integral I am trying to calculate:
\begin{equation}U_\pi(w)=\int_{-0.2}^{0.2} (1-e^{(-kx)}) \frac{1}{\sqrt2\hat{\sigma^2}}e^{-\frac{(x-\hat{\mu})^2}{2\hat{\sigma^2}}}dx \end{equation}
And the code:
k=1;
s=1000;
stocks_data=stockdata(:,2:8); log_stock_data_matrix=log(stocks_data);
log_return_matrix=(log_stock_data_matrix(2:s,:)-log_stock_data_matrix(1:s-1,:))./(log_stock_data_matrix(1:s-1,:));
phat=mle(log_return_matrix(:,1)); mu_hat=phat(1); sigma_hat=phat(2) k=1
b=0.15; a=-0.15; F=@(x)(1-exp(-k.x)).(1/(sqrt(2*pi)*sigma_hat)).*exp(-((x-mu_hat).^2)/(2*sigma_hat.^2)) Expected_utility = quad(F,a,b)