Integral construction and betainv

1 回表示 (過去 30 日間)
Andreas S
Andreas S 2020 年 11 月 20 日
コメント済み: Star Strider 2020 年 11 月 20 日
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!

採用された回答

Star Strider
Star Strider 2020 年 11 月 20 日
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 件のコメント
Andreas S
Andreas S 2020 年 11 月 20 日
It works perfect. Thank you very much!!!
Star Strider
Star Strider 2020 年 11 月 20 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by