Filter löschen
Filter löschen

Integral construction and betainv

1 Ansicht (letzte 30 Tage)
Andreas S
Andreas S am 20 Nov. 2020
Kommentiert: Star Strider am 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!

Akzeptierte Antwort

Star Strider
Star Strider am 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 Kommentare
Andreas S
Andreas S am 20 Nov. 2020
It works perfect. Thank you very much!!!
Star Strider
Star Strider am 20 Nov. 2020
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by