How to calculate overlapping area of two cdf's?
이전 댓글 표시
Using my data (from vectors ZP and ZM), I used ksdensity to create a kernel pdf and from this I created the CDF's from each of ZP and ZM, which were plotted on the same figure:
%%%%%%%% plots kernel pdf %%%%%%%%%
figure(200); [f1,x1]=ksdensity(ZP); plot(x1,f1); hold on; [f2,x2]=ksdensity(ZM); plot(x2,f2);
%%%%%% plots cdf %%%%%%%%
figure(300); ksdensity(ZP,'support','positive','function','cdf',... 'npoints',1000); hold on; ksdensity(ZM,'support','positive','function','cdf',... 'npoints',1000);
I now have two cdf's (see image) and if I fill the area below each, there will be a small overlapping region. I would like to calculate the area of that overlapping region and would very much appreciate any assistance with this.

답변 (1개)
Brendan Hamm
2015년 7월 6일
You could approach this with a Riemann sum or trapezoid rule, but to do this you would want to analyze the density at the same points:
pts = linspace(0,2.5e-3,100); % Based on your plot I choose these points
f1 = ksdensity(ZP,pts,'function','cdf')
f2 = ksdensity(ZM,pts,'function','cdf')
% Cumulative area between curves using trapezoidal rule (assuming f1 > f2 everywhere):
d = cumtrapz(pts,f1-f2);
totalArea = d(end)
카테고리
도움말 센터 및 File Exchange에서 Exploration and Visualization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!