-
Notifications
You must be signed in to change notification settings - Fork 25
/
PlotExp.m
65 lines (55 loc) · 2.3 KB
/
PlotExp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function [c2,cn2]=PlotExp(x,y,z2,lambda,xmin2,sCol)
%%
% Author: Roberto Rizzo
% Aberdeen May 2015
% [c2,cn2]=PlotExp(x,z2,lambda,xmin2)
% Generate the plot of the sorted empirical data (z2), and the
% theoretical curve obtained using the MLE for lambda and xmin.
%% Copyright
% Permission is hereby granted, free of charge, to any person obtaining a
% copy of this software and associated documentation files (the
% "Software"), to deal in the Software without restriction, including
% without limitation the rights to use, copy, modify, merge, publish,
% distribute, sublicense, and/or sell copies of the Software, and to permit
% persons to whom the Software is furnished to do so, subject to the
% following conditions:
%
% The above copyright notice and this permission notice shall be included
% in all copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
% OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
% NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
% DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
% OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
% USE OR OTHER DEALINGS IN THE SOFTWARE.
%%
% Handles for the plot
h = zeros(2,1);
x=unique(x);
% Construct the empirical C.D.F.
c2 = [sort(x) (length(x):-1:1)'./length(x)];
% Construct the theoretical C.D.F.
cn2 = [z2 (exp((lambda).*(xmin2-z2)))];
cn2(:,2) = cn2(:,2).* c2(find(c2(:,1)>=xmin2,1,'first'),2);
f = figure;
h(1) = semilogy(c2(:,1),c2(:,2),':s','Color',sCol,'MarkerSize',8,'MarkerFaceColor',sCol);
hold on
h(2) = semilogy(cn2(:,1),cn2(:,2),'-.','Color','k','LineWidth',1);
PosLc = max(y);
PosUc = min(y);
YL = ylim();
plot([PosUc PosUc], YL, 'r--')
plot([PosLc PosLc], YL, 'r--')
hold off
grid on
%set (gca, 'FontSize', 20, 'FontName', 'Calibri');
title('Exponential Distribution MLE');
legend('Observed Data','Estimated Data','Upper cut-off', 'Lower cut-off');
ylabel('Pr(l \geq l)');
xlabel('Length, units')
dim = [ .2 .025 .3 .3 ] ;
str = [ '\lambda = ', num2str(lambda) ] ;
annotation('textbox', dim, 'String', str, 'FitBoxToText', 'on', 'BackgroundColor', 'w') ;
end