Cumulative Contribution Contour Plot
이전 댓글 표시
I have a 2D weighting function of a certain area that gives 1 when summed over all columns and rows. I want to make a contour plot where the iso-lines represent the percentage cumulative contribution to the total. I have seen several questions on the web that refer to this exercise but found no answer. Can anyone help?
..
Below an example that illustrates what contour.m gives (which is not what I want):
% Construct Example Weighting Function
x1 = -3:.02:3; x2 = -3:.02:3;
[X1,X2] = meshgrid(x1,x2);
F = mvnpdf([X1(:) X2(:)],[0 0],[.25 .3; .3 1]);
F = reshape(F,length(x2),length(x1));
F = F./sum(sum(F));
..
% Make Contour Plot
[C,h] = contour(x1,x2,F,10);
set(gca,'xlim',[-1.5,1.5],'ylim',[-2.5,2.5]);
clabel(C,h,'labelspacing',500)
..
--> Rather then these standard contour lines I want the first iso-line to represent the first 10% contribution to the total, the next contour line the 20% contribution to the total etc.
채택된 답변
추가 답변 (3개)
Andrew Newell
2011년 1월 26일
You seem to be trying to plot the multivariate normal cumulative distribution function. For that, just change mvnpdf to mvncdf. You don't need the normalization step. Try this:
[X1,X2] = meshgrid(x1,x2);
F = mvncdf([X1(:) X2(:)],[0 0],[.25 .3; .3 1]);
[C,h] = contour(x1,x2,F,10);
set(gca,'xlim',[-1.5,1.5],'ylim',[-2.5,2.5]);
clabel(C,h,'labelspacing',500)
Andrew Newell
2011년 1월 27일
0 개 추천
Oscar, the real issue here is how to define the cdf for your function. Once you can calculate it, you can do a contour plot of it as you would any other function. The question that only you can answer is, how do you want to define that cdf? For example, mvncdf(X) calculates the probability that a random vector will fall within some semi-infinite rectangle with upper limits defined by X (see the documentation). To get the equivalent for your pdf, you'd need to be able to integrate it analytically or numerically (possibly using the Symbolic Toolbox or one of the Matlab quadrature functions). But there are other ways you could define it - for example, distance from the point where the maximum value occurs. It all depends on how you want to use this function.
John Moseley
2013년 6월 27일
0 개 추천
This is great Oscar. Thanks for posting.
John
카테고리
도움말 센터 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!