Effacer les filtres
Effacer les filtres

Integral construction and betainv

1 vue (au cours des 30 derniers jours)
Andreas S
Andreas S le 20 Nov 2020
Commenté : Star Strider le 20 Nov 2020
Hi everyone!!!
I need some help to construct the fun in order to run the integral that contains betainv.
My code is the following:
m=1000;
l=1000000*0.6;
pbar= [0.02,0.02,0.05,0.05,0.1,0.1];
rho=[0.2,0.8,0.2,0.8,0.2,0.8];
a=pbar.*(1-rho)./rho;
b= (1-pbar).*(1-rho)./rho;
format long
VaR_95=m*l*betainv(0.95,a,b)
VaR_99=m*l*betainv(0.99,a,b)
VaR_999=m*l*betainv(0.999,a,b)
alpha=0.95;
fun = @(a,b, alpha) l*m*betainv(0.95,a,b) ;
ES_95=(1/(1-alpha))*integral(@(alpha) fun(a,b, alpha),alpha,1)
In the end, in finding ES_95, matlab gives me errors and not result.
Thank you in advance!

Réponse acceptée

Star Strider
Star Strider le 20 Nov 2020
Since ‘pbar’ and ‘rho’ are vectors, use the 'ArrayValued' name-value pair in the integral call:
ES_95=(1/(1-alpha))*integral(@(alpha) fun(a,b, alpha),alpha,1, 'ArrayValued',1)
That worked when I tried it, and produced:
ES_95 =
1.0e+08 * [0.751401809017565 0.008479691310700 1.560368870762743 2.757477132869889 2.361442477520542 5.742979039200923]
.
  2 commentaires
Andreas S
Andreas S le 20 Nov 2020
It works perfect. Thank you very much!!!
Star Strider
Star Strider le 20 Nov 2020
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by