필터 지우기
필터 지우기

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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by