1classdef Exp < Markovian
2 % Exponential distribution with rate parameter lambda
4 % Fundamental distribution
for Markovian queueing systems with memoryless
property.
6 % Copyright (c) 2012-2026, Imperial College London
10 function self = Exp(lambda)
11 % EXP Create an exponential distribution instance
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});
24 function X = sample(self, n)
26 % Get n samples from the distribution
27 lambda = self.getParam(1).paramValue;
28 X = exprnd(1/lambda,n,1);
31 function phases = getNumberOfPhases(self)
32 % PHASES = GETNUMBEROFPHASES()
33 % Get number of phases in the underpinnning phase-type
38 function Ft = evalCDF(self,t)
39 % FT = EVALCDF(SELF,T)
40 % Evaluate the cumulative distribution function at t
43 lambda = self.getParam(1).paramValue;
44 Ft = 1-exp(-lambda*t);
47 function L = evalLST(self, s)
49 % Evaluate the Laplace-Stieltjes transform of the distribution function at t
52 lambda = self.getParam(1).paramValue;
53 L = lambda / (lambda + s);
56 function scv = getSCV(self)
60 function update(self,varargin)
61 % UPDATE(SELF,VARARGIN)
62 % Update parameters to match the first n central moments
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');
71 if abs(SKEW-2) > GlobalConstants.CoarseTol
72 line_warning(mfilename,
'The exponential distribution cannot fit skewness != 2, changing skewness to 2.\n');
74 %
if abs(KURT-9) > GlobalConstants.CoarseTol
75 % line_warning(mfilename,
'Warning: the exponential distribution cannot fit kurtosis != 9, changing kurtosis to 9.');
77 self.params{1}.paramValue = 1 / MEAN;
81 function setMean(self,MEAN)
82 % UPDATEMEAN(SELF,MEAN)
83 % Update parameters to match the given mean
84 self.params{1}.paramValue = 1 / MEAN;
86 self.immediate = MEAN < GlobalConstants.FineTol;
87 self.process = {[-1/MEAN],[1/MEAN]};
90 function setRate(self,RATE)
91 % UPDATERATE(SELF,RATE)
92 % Update rate parameter
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');
102 % self.params{1}.paramValue = 1 / MEAN;
104 % self.immediate = NaN;
110 function ex = fit(MEAN, SCV, SKEW)
111 % EX = FIT(MEAN, SCV, SKEW)
112 % Fit the distribution from three standard moments (mean,
115 ex.update(MEAN, SCV, SKEW);
118 function ex = fitMean(MEAN)
120 % Fit exponential distribution with given mean
121 ex = Exp(min(GlobalConstants.Immediate,max(GlobalConstants.Zero,1/MEAN)));
124 function ex = fitRate(RATE)
126 % Fit exponential distribution with given rate
127 ex = Exp(min(GlobalConstants.Immediate,max(GlobalConstants.Zero,RATE)));
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');
139 ex = Exp(1/GlobalConstants.Zero);
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));