2
$\begingroup$

Using the link Definition, it is possible to compute the entropic risk measure as follows: $$ EVaR=\text{inf}_{z>0}\{z^{-1}\ln\left(\frac{M_X(z)}{\alpha}\right)\}, $$ wherein $X$ is a random variable having a given distribution, $\alpha$ is the confidence level, and $M_X(z)$ is the moment generating function (MGF).

Hopefully since we have a command for MDF, I write the following lines for the normal distribution:

ClearAll["Global`*"]
X = NormalDistribution[\[Mu], \[Sigma]];
Mgf = MomentGeneratingFunction[X, z]
Mgf1 = Mgf/\[Alpha] // FullSimplify;
Mgf2 = PowerExpand[Log[Mgf1], 
   Assumptions -> {z >= 0, \[Mu] >= 0, \[Sigma] >= 0, 
     0 < \[Alpha] < 1}];
EVaR = Refine[1/z Mgf2,
   Assumptions -> {z >= 0, \[Mu] >= 0, \[Sigma] >= 0, 
     0 < \[Alpha] < 1}] // FullSimplify

Unfortunately this does not lead to the correct value $\sigma \sqrt{-2 \log (\alpha )}+\mu$.

Can anyone give some hints here how we can get the results or get rid of the $z$ variable in my code output?

Thanks.

$\endgroup$
3
$\begingroup$

Try this:

assumptions = DistributionParameterAssumptions[X] && 0 < α < 1 && z > 0;
Assuming[assumptions,
 FullSimplify @ Minimize[{EVaR, assumptions}, z]
]
(* {μ + σ Sqrt[Log[1/α^2]], {z -> Sqrt[Log[1/α^2]]/σ}} *)

edit

Since Minimize is not going to work for every distribution, you can use this function to get the EVaR for numeric distributions and numeric values of α:

EntropicValueAtRisk[dist_?DistributionParameterQ, α_?NumericQ] /; 
  NumericQ[RandomVariate[dist]] := Module[{
   mgf = MomentGeneratingFunction[dist, \[FormalZ]],
   assumptions
  },
   assumptions = Simplify[DistributionParameterAssumptions[dist] && \[FormalZ] > 0 && mgf > 0];
   NMinimize[
    {
     FullSimplify[1/\[FormalZ] Log[mgf/α], Assumptions -> assumptions],
     assumptions
    },
    \[FormalZ]
   ]
 ];

EntropicValueAtRisk[UniformDistribution[], 0.5]
(* {0.815172, {\[FormalZ] -> 5.26208}} *)
| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks. This line helps to get the results but why the whole code still does not give a same output for the UniformDistribution[{a,b}] as in the link of the question? $\endgroup$ – Fazlollah Feb 19 at 17:39
  • 1
    $\begingroup$ It just looks like Minimize can't find the minimum for that expression, unfortunately. If you give specific values for a, b and α, you can use NMinimize to find the minimum. $\endgroup$ – Sjoerd Smit Feb 20 at 9:28
  • $\begingroup$ Your edited response sounds much more useful. Is it possible to Compile your function so as to gain some speed while we call it in a loop? $\endgroup$ – Fazlollah Feb 20 at 14:13
  • $\begingroup$ NMinimize already compiles expressions internally wherever it can, so there's little point in trying to write your own compilation of this code since NMinimize is going to be the slowest step. The only optimization that makes sense here, is to use symbolic results from Minimize where possible (and then substitute parameter values) and only use NMinimize where necessary. $\endgroup$ – Sjoerd Smit Feb 20 at 14:29
  • 1
    $\begingroup$ Another optimization you could attempt, is to pre-compute a number of values of α for a given distribution and then use Interpolation to interpolate those values so you can get other α values more quickly (approximately). FunctionInterpolation might also work here (though it can be a bit flaky sometimes). $\endgroup$ – Sjoerd Smit Feb 20 at 14:37

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.