Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
How to integrate a distribution function for a specific interval?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I computed two distribution function:
[distribution_1,x]=ecdf(X); Distribution_2= f(distribution_1);
Now I want to integrate Distribution_2 over the interval [a,b] and tried to use q = integral(fun,xmin,xmax) but I have trouble creating the function handle "fun" in my specific case (since I cannot create the connection to x?)
Thankful for any advice!
5 comentarios
Respuesta aceptada
Robert
el 6 de Nov. de 2017
To make your empirical CDF into a function that integral can use, you should interpolate distribution_2. Because of the way the CDF is defined, I recommend you interpolate based on the previous value. The first value of x is a duplicate of the second, but for use with interp1(..., 'previous') it should be a (finite) number less than any you plan to use. -realmax should do the trick.
x(1) = -realmax;
f_dist2 = @(new_x) interp1(x, distribution_2, new_x, 'previous', 'extrap');
integral(f_dist2, -1, 1)
3 comentarios
Más respuestas (1)
David Goodmanson
el 6 de Nov. de 2017
Editada: David Goodmanson
el 6 de Nov. de 2017
Hi Nina,
If this is not a misinterpretation of the problem, then it seems to work. I am assuming that the function ecdf is already on the Matlab path.
g = .1; h = .2;
fun = @(x) 1-(1-ecdf(x).^(1/(1+g))).^(1+h)
integral(@(x) fun(x), 2,3)
function a = ecdf(x) % for demo purposes
a = sin(x);
end
I'm curious about the idea of integrating a cdf, could you perhaps comment on that?
1 comentario
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!