LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Exp.m
1classdef Exp < Markovian
2 % Exponential distribution with rate parameter lambda
3 %
4 % Fundamental distribution for Markovian queueing systems with memoryless property.
5 %
6 % Copyright (c) 2012-2026, Imperial College London
7 % All rights reserved.
8
9 methods
10 function self = Exp(lambda)
11 % EXP Create an exponential distribution instance
12 %
13 % @brief Creates an exponential distribution with the given rate parameter
14 % @param lambda Rate parameter (must be positive)
15 % @return self Exp distribution instance with rate lambda
16 self@Markovian('Exp', 1);
17 setParam(self, 1, 'lambda', lambda);
18 self.immediate = (1/lambda) < GlobalConstants.FineTol;
19 self.obj = jline.lang.processes.Exp(lambda);
20 self.process = {[-lambda],[lambda]};
21 self.nPhases = length(self.process{1});
22 end
23
24 function X = sample(self, n)
25 % X = SAMPLE(N)
26 % Get n samples from the distribution
27 lambda = self.getParam(1).paramValue;
28 X = exprnd(1/lambda,n,1);
29 end
30
31 function phases = getNumberOfPhases(self)
32 % PHASES = GETNUMBEROFPHASES()
33 % Get number of phases in the underpinnning phase-type
34 % representation
35 phases = 1;
36 end
37
38 function Ft = evalCDF(self,t)
39 % FT = EVALCDF(SELF,T)
40 % Evaluate the cumulative distribution function at t
41 % AT T
42
43 lambda = self.getParam(1).paramValue;
44 Ft = 1-exp(-lambda*t);
45 end
46
47 function L = evalLST(self, s)
48 % L = EVALST(S)
49 % Evaluate the Laplace-Stieltjes transform of the distribution function at t
50 % AT T
51
52 lambda = self.getParam(1).paramValue;
53 L = lambda / (lambda + s);
54 end
55
56 function scv = getSCV(self)
57 scv = 1.0;
58 end
59
60 function update(self,varargin)
61 % UPDATE(SELF,VARARGIN)
62 % Update parameters to match the first n central moments
63 % (n<=4)
64 MEAN = varargin{1};
65 SCV = varargin{2};
66 SKEW = varargin{3};
67 % KURT = varargin{4};
68 if abs(SCV-1) > GlobalConstants.CoarseTol
69 line_warning(mfilename,'The exponential distribution cannot fit squared coefficient of variation != 1, changing squared coefficient of variation to 1.\n');
70 end
71 if abs(SKEW-2) > GlobalConstants.CoarseTol
72 line_warning(mfilename,'The exponential distribution cannot fit skewness != 2, changing skewness to 2.\n');
73 end
74 % if abs(KURT-9) > GlobalConstants.CoarseTol
75 % line_warning(mfilename,'Warning: the exponential distribution cannot fit kurtosis != 9, changing kurtosis to 9.');
76 % end
77 self.params{1}.paramValue = 1 / MEAN;
78 self.immediate = NaN;
79 end
80
81 function setMean(self,MEAN)
82 % UPDATEMEAN(SELF,MEAN)
83 % Update parameters to match the given mean
84 self.params{1}.paramValue = 1 / MEAN;
85 self.mean = MEAN;
86 self.immediate = MEAN < GlobalConstants.FineTol;
87 self.process = {[-1/MEAN],[1/MEAN]};
88 end
89
90 function setRate(self,RATE)
91 % UPDATERATE(SELF,RATE)
92 % Update rate parameter
93 self.setMean(1/RATE);
94 end
95
96 % function setMeanAndSCV(self,MEAN,SCV)
97 % % UPDATEMEANANDSCV(SELF,MEAN,SCV)
98 % % Update parameters to match the given mean and squared coefficient of variation (SCV=variance/mean^2)
99 % if abs(SCV-1) > GlobalConstants.CoarseTol
100 % line_warning(mfilename,'The exponential distribution cannot fit SCV != 1, changing SCV to 1.\n');
101 % end
102 % self.params{1}.paramValue = 1 / MEAN;
103 % self.mean = MEAN;
104 % self.immediate = NaN;
105 % end
106
107 end
108
109 methods (Static)
110 function ex = fit(MEAN, SCV, SKEW)
111 % EX = FIT(MEAN, SCV, SKEW)
112 % Fit the distribution from three standard moments (mean,
113 % scv, skewness)
114 ex = Exp(1);
115 ex.update(MEAN, SCV, SKEW);
116 end
117
118 function ex = fitMean(MEAN)
119 % EX = FITMEAN(MEAN)
120 % Fit exponential distribution with given mean
121 ex = Exp(min(GlobalConstants.Immediate,max(GlobalConstants.Zero,1/MEAN)));
122 end
123
124 function ex = fitRate(RATE)
125 % EX = FITRATE(RATE)
126 % Fit exponential distribution with given rate
127 ex = Exp(min(GlobalConstants.Immediate,max(GlobalConstants.Zero,RATE)));
128 end
129
130 function ex = fitMeanAndSCV(MEAN, SCV)
131 % EX = FITMEANANDSCV(MEAN, SCV)
132 % Fit exponential distribution with given mean and squared coefficient of variation (SCV=variance/mean^2)
133 if abs(SCV-1) > GlobalConstants.CoarseTol
134 line_warning(mfilename,'The exponential distribution cannot fit SCV != 1, changing SCV to 1.\n');
135 end
136 if MEAN>0
137 ex = Exp(1/MEAN);
138 else
139 ex = Exp(1/GlobalConstants.Zero);
140 end
141 end
142
143 function Qcell = fromMatrix(Lambda)
144 % QCELL = FROMMATRIX(LAMBDA)
145 % Instantiates a cell array of Exp objects, each with rate
146 % given by the entries of the input matrix
147 Qcell = cell(size(Lambda));
148 for i=1:size(Lambda,1)
149 for j=1:size(Lambda,2)
150 Qcell{i,j} = Exp.fitRate(Lambda(i,j));
151 end
152 end
153 end
154 end
155
156end