0
$\begingroup$

I am trying to find the expectation of a relatively simple expression under a lognormal distribution with mean [Mu] - [Sigma]^2/2 and variance [Sigma]^2 , but it hangs for a long while and eventually returns the original question:

In[36]:= Expectation[(2 Sqrt[x])/(x + 1) - 1, 
 x \[Distributed] 
  LogNormalDistribution[ (\[Mu] - \[Sigma]^2/2), \[Sigma]]]

Out[36]= Expectation[-1 + (2 Sqrt[x])/(1 + x), 
 x \[Distributed] 
  LogNormalDistribution[\[Mu] - \[Sigma]^2/2, \[Sigma]]]

I have tried putting an Abs[] around the Sqrt[] to only take the positive root just in case that was the issue, without success. I have also tried adding Assumptions to the effect that x>0, [Sigma] > 0 but that made no difference.

Any pointers greatly appreciated!

$\endgroup$
2
  • 3
    $\begingroup$ You are effectively asking Mathematica to integrate: $$\int_{0}^{\infty}{\frac{\left(\frac{2 \sqrt{x}}{x+1}-1\right) e^{-\frac{\left(-2 \mu +\sigma ^2+2 \log (x)\right)^2}{8 \sigma ^2}}}{\sqrt{2 \pi } \sigma x}}dx$$ This integral is too difficult so it's giving up. $\endgroup$
    – flinty
    Oct 6, 2021 at 10:24
  • $\begingroup$ Just curious: are you sure about wanting LogNormalDistribution[\[Mu] - \[Sigma]^2/2, \[Sigma]] ? I ask because the mean of that distribution is $e^\mu$ and the variance is $\left(e^{\sigma^2}-1\right) e^{2 \left(m-\frac{\sigma^2}{2}\right)+\sigma^2}$ (not $\sigma^2$). In other words your first sentence talks about the two values listed as if those are the mean and variance. But the way Mathematica parameterizes things, those are just the two parameters. $\endgroup$
    – JimB
    Oct 6, 2021 at 16:14

2 Answers 2

1
$\begingroup$

This can be done numerically:

f[\[Mu]_?NumericQ, \[Sigma]_?NumericQ] :=  NExpectation[(2 Sqrt[x])/(x + 1) - 1, 
x \[Distributed] LogNormalDistribution[ (\[Mu] - \[Sigma]^2/2), \[Sigma]]];
f[1, 2]

-0.295453

$\endgroup$
1
  • $\begingroup$ +1 For formatting tools see link $\endgroup$
    – Bob Hanlon
    Oct 6, 2021 at 13:22
0
$\begingroup$

Many thanks for all the helpful comments. On the variance, if you don't subtract Sigma^2/2 then the mean will not be mu. The variance I meant is the variance of log returns not the variance of returns, so that is OK. I tried the numerical integration and it gives me useful results which I can plot and make sense of, which is very helpful. An analytical solution would be even better if I could get one. Is there any way to tease an analytic answer out for the hard integral by breaking it up? I tried but it seems to give up as "too difficult" very early. For example, it can do the integral for 1/x, but it already starts to choke on 1/(1+x), which doesn't seem particularly complex...

$\endgroup$
1
  • 1
    $\begingroup$ This information should be added in your original question by editing it, or as a comment on another answer if appropriate. "Answers" on this site are not used to continue a conversation, but are really reserved for proposing a solving approach to the question. $\endgroup$
    – MarcoB
    Oct 7, 2021 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.