I am stuck with the following problem using MATLAB:
Let Z be lognormally distributed such that ln Z has mean m and variance w. Let eta be a negative number and c a positive constant.
I am trying to compute the expected value (let I(Z<=c) denote the indicator function of the set (Z<=c))
E[Z^(eta+1) I(Z<=c)] = (1/sqrt(w)) integral_0^c x^(eta) phi((ln x - m)/sqrt(w)) dx,
where phi() denotes the probability distribution function of a standard normal random variable.
First thing I did was to simulate 10.000 trials of Z, set the entries of the vector with value >c to 0, raised to the power of (eta+1) and then calculated the mean. This should give me the MC estimate of the expected value.
ST = random('Lognormal', m,w_sq,10000,1);
hlp = zeros(10000,1);
hlp(ST<=2) = ST(ST<=2);
hlp(hlp>0) = hlp(hlp>0).^(eta1+1); % 0^(eta1+1) gives infinity
mean(hlp)
For the integral I used the following code
tmpp = integral(@(x) x.^(eta1) .* normpdf((log(x)-m)/sqrt(w_sq),0,c);
tmpp / sqrt(w_sq(1))
Unfortunately the procedures lead to totally different results, although mathematically they should be they same.
This whole thing is part of a bigger code and it would be a lot more convenient for me to use the integral version. Originally I tried to double check using the MC simulation and then saw that something must be wrong...
Can someone help?
See Question&Answers more detail:os