how does cdfplot works?

4 次查看(过去 30 天)
can someone tell me how cdfplot works....? i know the matlab help about this function but i dont understand it...the answer in my code is upside down but it should be like this picture...
clc;
clear;
C=[250;200;150;150;100];
q=[0.15;0.15;0.1;0.1;0];
y=[660;660;770;880];
f=[10;15;20;25;30;50];
Aeq=ones(1,6);
LB=zeros(6,1);
prob=[0.25;0.25;0.25;0.25];
%% Monte Carlo
iteration=3000;% Number of iterations
deterministic_index=zeros(iteration,1);
margin=zeros(iteration,1);
for t=1:iteration
%generation program
for i=1:length(C)
if rand<=q(i)
outage_capacity(i)=C(i);
UB1(i)=0;
else
UB1(i)=C(i);
outage_capacity(i)=0;
end
end
%% Load random samples
sum_prob(1)=prob(1);
for i=2:length(prob)
sum_prob(i)=sum_prob(i-1)+prob(i);
end
flag=find(rand<=sum_prob);
load=y(min(flag));
%% Margin random variable
margin(t) = sum(C) - sum(outage_capacity) - load;
if margin(t)<0
deterministic_index(t)=1;
end
beq=load;
UB=[UB1,beq] ;
[X,faval,exitflag]=linprog(f,[],[],Aeq,beq,LB,UB);
X1(:,t)=X;
end
C1 = X1(1,:);
C2 = X1(2,:);
C3 = X1(3,:);
C4 = X1(4,:);
C5 = X1(5,:);
Plsh = X1(6,:);
% Plsh=Plsh(end:-1:1);
ExpectationC1 = mean(C1);
ExpectationC2 = mean(C2);
ExpectationC3 = mean(C3);
ExpectationC4 = mean(C4);
ExpectationC5 = mean(C5);
ExpectationPlsh = mean(Plsh);
standard_deviationC1 = std(C1);
standard_deviationC2 = std(C2);
standard_deviationC3 = std(C3);
standard_deviationC4 = std(C4);
standard_deviationC5 = std(C5);
standard_deviationPlsh = std(Plsh);
LOLP = mean(deterministic_index);
LOLE = 8760*LOLP;
EENS = mean(mean(margin .* deterministic_index));
disp(['LOLP=',num2str(LOLP)]);
disp(['LOLE=',num2str(LOLE)]);
disp(['EENS=',num2str(EENS)]);
disp(['ExpectationC1=',num2str(ExpectationC1)]);
disp(['ExpectationC2=',num2str(ExpectationC2)]);
disp(['ExpectationC3=',num2str(ExpectationC3)]);
disp(['ExpectationC4=',num2str(ExpectationC4)]);
disp(['ExpectationC5=',num2str(ExpectationC5)]);
disp(['ExpectationPlsh=',num2str(ExpectationPlsh)]);
disp(['standard_deviationC1=',num2str(standard_deviationC1)]);
disp(['standard_deviationC2=',num2str(standard_deviationC2)]);
disp(['standard_deviationC3=',num2str(standard_deviationC3)]);
disp(['standard_deviationC4=',num2str(standard_deviationC4)]);
disp(['standard_deviationC5=',num2str(standard_deviationC5)]);
disp(['standard_deviationPlsh=',num2str(standard_deviationPlsh)]);
disp(['Exitflag=',num2str(exitflag)]);
%% Probability Density Function
figure(1);
subplot(3,2,1); hist(C1); title('Probability Density Function(Unit1)');
subplot(3,2,2); hist(C2); title('Probability Density Function(Unit2)');
subplot(3,2,3); hist(C3); title('Probability Density Function(Unit3)');
subplot(3,2,4); hist(C4); title('Probability Density Function(Unit4)');
subplot(3,2,5); hist(C5); title('Probability Density Function(Unit5)');
figure(2);
hist(Plsh); title('Probability Density Function(Plsh)');
%%Cumulative distribution function
figure(3);
subplot(5,1,1); cdfplot(C1); title('Cumulative distribution function(Unit1)');
subplot(5,1,2); cdfplot(C2); title('Cumulative distribution function(Unit2)');
subplot(5,1,3); cdfplot(C3); title('Cumulative distribution function(Unit3)');
subplot(5,1,4); cdfplot(C4); title('Cumulative distribution function(Unit4)');
subplot(5,1,5); cdfplot(C5); title('Cumulative distribution function(Unit5)');
figure(4);
cdfplot(Plsh);
  7 个评论
Torsten
Torsten 2022-12-10
编辑:Torsten 2022-12-10
As you see from my answer, you get access to the x and y plot data by
h = cdfplot(x)
x = h.XData
y = h.YData
Now you can rearrange the data according to your needs.
I mention this because I'm still not sure whether the suggested rearrangement is correct in your case. You will have to check it carefully.

请先登录,再进行评论。

采纳的回答

the cyclist
the cyclist 2022-12-10
What you are plotting is known as a "survival" curve, and I think it is possible that you want to use the ecdf function instead of cdfplot. That function allows you to specify that you are using a survival function.
  2 个评论
arian hoseini
arian hoseini 2022-12-10
tried it not working...
the cyclist
the cyclist 2022-12-10
Here is the equivalent to what @Torsten posted as an example:
x = rand(1000,1);
ecdf(x,'Function','survivor');

请先登录,再进行评论。

更多回答(0 个)

标签

产品


版本

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by