How to obtain CDF from the below PDF function
Mostrar comentarios más antiguos
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 comentarios
David Goodmanson
el 16 de Dic. de 2019
Hi Manesf,
Mu_d = ? Mu_D = ?
David Goodmanson
el 16 de Dic. de 2019
I ran the integration and got a 'minimum step size reached' error and not .6449. Matlab R2019b update 1.
the cyclist
el 16 de Dic. de 2019
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
el 17 de Dic. de 2019
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
el 17 de Dic. de 2019
MANESF
el 17 de Dic. de 2019
David Goodmanson
el 17 de Dic. de 2019
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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Debugging and Analysis en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
