How to obtain CDF from the below PDF function
이전 댓글 표시
I am kind of new to MATLAB and I want to obtain the empitical cumulative distribution function (CDF) of the below PDF:

where:
the PDF function is as follows:
GEV_function=@(y) (Gamma_d.*Gamma_D)./(Delta_t.*Etta_d.*Etta_D).*(1./y).*(exp(-(1-(Mu_d.*Gamma_d)+(Gamma_d.*x)./y).^((-1)./Etta_d))./exp((1-(Mu_D.*Gamma_D)+(Gamma_D.*y)./Delta_t).^((-1)./Etta_D))).*(1-(Mu_d.*Gamma_d)+(Gamma_d.*x)./y).^(-1-(1./Etta_d)).*(1-Mu_D.*Gamma_D+Gamma_D.*y./Delta_t).^(-1-(1./Etta_D));
PDF=integral(GEV_function,0,inf);
To obtain the CDF and to check if I get CDF = 1 as x approuches to infinity, I have integrated the f(x) from minus infinity to positive infinity as follows:
GEV_Original=@(y,x) (Gamma_d.*Gamma_D)./(Delta_t.*Etta_d.*Etta_D).*(1./y).*(exp(-(1-(Mu_d.*Gamma_d)+(Gamma_d.*x)./y).^((-1)./Etta_d))./exp((1-(Mu_D.*Gamma_D)+(Gamma_D.*y)./Delta_t).^((-1)./Etta_D))).*(1-(Mu_d.*Gamma_d)+(Gamma_d.*x)./y).^(-1-(1./Etta_d)).*(1-Mu_D.*Gamma_D+Gamma_D.*y./Delta_t).^(-1-(1./Etta_D));
CDF = integral2(GEV_Original,0,inf,-inf,inf)
But the answer is 0.6449 and not 1.
I guess the usage of double integral is leading to such an error. Is my code correct?
I appreciate any thoughts or help.
댓글 수: 9
David Goodmanson
2019년 12월 16일
Hi Manesf,
Mu_d = ? Mu_D = ?
David Goodmanson
2019년 12월 16일
I ran the integration and got a 'minimum step size reached' error and not .6449. Matlab R2019b update 1.
the cyclist
2019년 12월 16일
Can you please double-check what you have posted? I copied your values and formulas directly from here. I then ran the code
x = 0:0.01:1;
y = -1:0.01:1;
[xx,yy] = ndgrid(x,y);
figure
mesh(xx,yy,PDF(xx,yy))
to see what the pdf looked like, and I got negative values:

Here is the code I calculated with. I don't think I mistranscribed anything.
Delta_t = 25;
Etta_d = 0.02;
Etta_D = 0.08;
Mu_d = -2.95;
Mu_D = 0.05;
Gamma_d = (gamma(1-Etta_d) - 1)./(1-Mu_d);
Gamma_D = (gamma(1-Etta_D) - 1)./(1-Mu_D);
PDF=@(x,y) (Gamma_d.*Gamma_D)/(Delta_t.*Etta_d.*Etta_D).*(1./y).*(exp(-(1-(Mu_d.*Gamma_d)+(Gamma_d.*x)./y).^((-1)./Etta_d))./exp((1-(Mu_D.*Gamma_D)+(Gamma_D.*y)./Delta_t).^((-1)./Etta_D))).*(1-(Mu_d.*Gamma_d)+(Gamma_d.*x)./y).^(-1-(1./Etta_d)).*(1-Mu_D.*Gamma_D+Gamma_D.*y./Delta_t).^(-1-(1./Etta_D));
Jesus Sanchez
2019년 12월 17일
Isn't this a problem of the order of the integral operations? First the PDF should be integrated in terms of y and then the result should be integrated in terms of x to get the CDF
MANESF
2019년 12월 17일
MANESF
2019년 12월 17일
David Goodmanson
2019년 12월 17일
Hi Manesf,
So far it looks like x ( -inf<=x<=inf ) and y ( 0 <= y <= inf ) can be varied completely independently. In that case, suppose that 1/Etta_d is not an integer. There is sure to be a region of x and y where
( 1 - Mu_d.*Gamma_d + Gamma_d *x/y )
is negative, in which case
( 1 - Mu_d.*Gamma_d + Gamma_d *x/y ) ^( (-1)/Etta_d) )
is complex, not real. So it appears that something is not quite right.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
