title: matlab conditional expectation seems not to work for lognormal
body: <p>I have already tried similar code for other distributions (exponential, normal etc) and in those cases the code works. 
  However for the lognormal distribution case there seems to be a problem in the way matlab computes the numerical integral.</p>
  
  <p>The code:</p>
  
  <pre><code>function y=condint(sigma,mi,phihat)
  y=quad(@phipr,phihat,110,0.000000000000001)
  
      function y=phipr(x)
        y=1./(1-logncdf(phihat)).*1/(2*pi*sigma^2).^(1/2).*exp(-((log(x)-mi).^2)./(2*sigma^2));
      end
  end
  </code></pre>
  
  <p>it fails to have the obvious property that the conditional expected value for higher cutoffs (phihat) should be higher. Is this a generic problem of the numerical procedures for a distribution that decays very fast? Is this a known problem?
  Thank you for your help</p>
  
  <p>P.s. In the above I used as upper bound 110, because when using parameters mi=0 and sigma=0.25 using higher values would give wierd results even for the cdf. Again is this related with problems in the trapeziod integral approximation?</p>