Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: How to shade area between two eCDFs with different vector sizes
Replies: 0

 Aytekin Gel Posts: 1 Registered: 12/3/12
How to shade area between two eCDFs with different vector sizes
Posted: Dec 3, 2012 6:09 PM

Hello,

I am trying to shade or fill the area between two empirical CDFs with single color. I reviewed the prior posts about fill or patch commands but unfortunately couldn't make use of it for this particular case where I have 100 samples for first eCDF (variable name: Yk) and 11 samples for the second eCDF (variable name : Yk_exp).

Attached below is a small prototype code to represent what I tried. I was able to use fill to create the yellow shaded area between two eCDFs with same size of vectors (L0 = fill (Val_x, Val_y,'y')). However, I also need to shade the area between two eCDFs shown as most right of the yellow shaded region and red line, which have different sizes.

Any suggestions will be greatly appreciated, sorry for the long message.

Thanks for your help and time,

Aytekin

P.S.
Matlab script:
% Input propagation data
Y = [
1.9102051410387489e+01
1.9196680482819982e+01
1.9553051526315382e+01
1.8604292110167986e+01
1.8559913631880018e+01
1.8763620742120445e+01
1.9006847393775935e+01
1.8973150699504238e+01
1.9060291749919053e+01
1.8592048442247727e+01
1.9314131706573530e+01
1.8923958835331717e+01
1.9483188206081330e+01
1.8921867375964251e+01
1.8632910595374380e+01
1.8859875879573757e+01
1.8974499130682180e+01
1.9183333056517533e+01
1.8802524386018469e+01
1.9362983124106421e+01
1.9089234745240724e+01
1.9121353802487178e+01
1.9133867730577705e+01
1.8854620382078195e+01
1.8443741731012942e+01
1.8612708503300546e+01
1.9394038334977349e+01
1.9246205247922575e+01
1.8885203040396895e+01
1.9305971639309163e+01
1.9278493088620053e+01
1.9089131644726983e+01
1.9073370244873459e+01
1.8855846323117241e+01
1.9426455893493682e+01
1.8749412828263409e+01
1.9069512825324107e+01
1.8539452367826069e+01
1.9198375163368123e+01
1.9212864160034876e+01
1.9707054892545244e+01
1.8801834726125108e+01
1.9070719258817689e+01
1.8912303971450790e+01
1.9568896883242935e+01
1.8999053052805809e+01
1.9517528229517456e+01
1.8925130556545831e+01
1.9275555892478732e+01
1.9224163017275320e+01
1.9314226855968023e+01
1.8949177507393593e+01
1.8857686616835650e+01
1.9039005577712576e+01
1.9174378354531612e+01
1.8811848819954069e+01
1.8686562730426701e+01
1.9048294127266001e+01
1.8774689224470784e+01
1.9261800279550894e+01
1.9048477172043320e+01
1.9050433688428711e+01
1.8985112442147202e+01
1.8865364622441085e+01
1.8952863999499534e+01
1.8826588105287833e+01
1.8936769242021693e+01
1.8818101570147412e+01
1.8731641749457793e+01
1.9009751353614803e+01
1.8806570381737433e+01
1.9384550619546857e+01
1.9054257919723735e+01
1.9024154904495198e+01
1.8674127417449924e+01
1.9032562038746342e+01
1.8865169599154196e+01
1.9364938402742567e+01
1.8897246449657771e+01
1.9505721693149056e+01
1.9052910089073073e+01
1.8938253055286662e+01
1.9324821945119240e+01
1.8620458077790559e+01
1.9315959830706941e+01
1.9099361446539728e+01
1.9036047677416239e+01
1.9059673302607102e+01
1.8827671310010093e+01
1.8827250144574045e+01
1.8953121598286813e+01
1.9021871779357511e+01
1.9105948451757030e+01
1.9231835229537754e+01
1.8757428024499500e+01
1.9181204676828024e+01
1.8777812783790843e+01
1.8562131663363225e+01
1.8928153357390471e+01
1.9360248154665840e+01
];

% Experimental data
Yk_exp = [20.83901004
19.77982358
21.16466533
21.25291928
19.81742617
19.92574407
20.58645521
20.38834009
19.5102916
19.77407095
20.22642447];

Yk = sort(Y(:,1));
Xk = 1 : 100;
Xk = Xk / 100;

% Set the discrepency to be appended both sides of input propagation
U_discrepency = 0.004;

% Calculate left and right CDFs for input propagation
SRQ_left = transpose(Y*(1-U_discrepency));
SRQ_right = transpose(Y*(1+U_discrepency));

Val_x = [sort(SRQ_left,'ascend') sort(SRQ_right,'descend')];
Val_y = [Xk sort(Xk,'descend')];

hold on
% Plot filled region for input propagation uncertainty
L0 = fill (Val_x, Val_y,'y');

% Plot input propagation CDF
plot(Yk, Xk, 'lineWidth',3)
set(gca,'linewidth',2)
set(gca,'fontweight','bold')
set(gca,'fontsize',12)

% Plot experimental empirical CDF
[ExpCDF,Expstats]=cdfplot(Yk_exp);
set(ExpCDF,'Color','r','lineWidth',3);
[CDF_Exp,Xkexp] = ecdf(Yk_exp);

% TESTING DIFFERENT OPTIONS: TO SHADE BETWEEN RIGHT SIDE of YELLOW shaded area and RED line
%patch([y1 fliplr(y2)], [x,fliplr(x2)],'g')
%fill([SRQ_right fliplr(Xkexp')], [Xk,fliplr(CDF_Exp')],'g')

grid on
box on