1classdef Distribution < Copyable
2 % Distribution Abstract base
class for statistical distributions
4 % Distribution provides the common
interface and functionality for all
5 % statistical distributions used in queueing models. It defines abstract
6 % methods
for sampling, computing moments, and obtaining distribution
7 % properties that must be implemented by concrete distribution
classes.
9 % @brief Abstract base
class for all statistical distribution types
11 % Key characteristics:
12 % - Abstract
interface for all distributions
13 % - Support
for both discrete and continuous distributions
14 % - Moment computation (mean, variance, SCV)
15 % - Random sampling capabilities
16 % - Parameter management and validation
17 % - Copyable
interface for cloning distributions
19 % Distribution hierarchy includes:
20 % - Continuous distributions (Exp, Erlang, HyperExp, etc.)
21 % - Discrete distributions (Poisson, Bernoulli, Zipf, etc.)
22 % - Phase-type distributions (PH, APH, Coxian, etc.)
23 % - Markov-modulated processes (MAP, MMPP, etc.)
25 % Common usage patterns:
27 % dist = Exp(1.5); % Exponential with rate 1.5
28 % mean_val = dist.getMean(); % Get mean value
29 % samples = dist.sample(100); % Generate 100 samples
32 % Copyright (c) 2012-2026, Imperial College London
33 % All rights reserved.
37 immediate; %
true if immediate
44 support; % support interval
49 function X = sample(self,n)
50 % SAMPLE Generate random samples from the distribution
52 % @brief Generates n random samples from
this distribution
53 % @param n Number of samples to generate
54 % @
return X Vector of n random samples
55 line_error(mfilename,
'An abstract method was called. The function needs to be overridden by a subclass.');
58 function RATE = getRate(self)
59 % GETRATE Get the rate parameter (inverse of mean)
61 % @brief Returns the rate parameter defined as 1/mean
62 % @
return RATE Rate parameter (1/mean)
63 RATE = 1 / getMean(self);
66 function MEAN = getMean(self)
68 % Get distribution mean
69 line_error(mfilename,
'An abstract method was called. The function needs to be overridden by a subclass.');
72 function SCV = getSCV(self)
74 % Get distribution squared coefficient of variation (SCV = variance / mean^2)
75 line_error(mfilename,
'An abstract method was called. The function needs to be overridden by a subclass.');
78 function VAR = getVar(self)
80 % Get distribution variance
81 VAR = getSCV(self)*getMean(self)^2;
84 function SKEW = getSkewness(self)
85 % SKEW = GETSKEWNESS()
86 % Get distribution skewness
87 line_error(mfilename,
'An abstract method was called. The function needs to be overridden by a subclass.');
90 function Ft = evalCDF(self,t)
91 % FT = EVALCDF(SELF,T)
92 % Evaluate the cumulative distribution function at t
93 line_error(mfilename,
'An abstract method was called. The function needs to be overridden by a subclass.');
96 function L = evalLST(self, s)
97 % L = EVALLAPLACETRANSFORM(S)
98 % Evaluate the Laplace transform of the distribution function at t
99 line_error(mfilename,
'An abstract method was called. The function needs to be overridden by a subclass.');
105 function self = Distribution(name, numParam, support)
106 % SELF = DISTRIB(NAME, NUMPARAM, SUPPORT)
107 % Construct a distribution from name, number of parameters, and
110 self.support = support;
111 self.setNumParams(numParam);
112 self.immediate =
false;
117 function nParam = setNumParams(self, numParam)
118 % NPARAM = SETNUMPARAMS(NUMPARAM)
119 % Initializes the parameters
120 self.params = cell(1,numParam);
122 self.params{i}=
struct(
'paramName',
'',
'paramValue',NaN);
126 function nParam = getNumParams(self)
127 % NPARAM = GETNUMPARAMS()
128 % Returns the number of parameters needed to specify the distribution
129 nParam = length(self.params);
132 function setParam(self,
id, name, value)
133 % SETPARAM(ID, NAME, VALUE, TYPECLASS)
134 % Set a distribution parameter given id, name, value, Java
135 %
class type (for JMT translation)
136 self.params{
id}.paramName=name;
137 self.params{
id}.paramValue=value;
140 function param = getParam(self,
id)
141 % PARAM = GETPARAM(SELF,ID)
142 % Return the parameter associated to the given
id
143 param = self.params{
id};
146 function
bool = isDisabled(self)
147 % BOOL = ISDISABLED()
148 % Check
if the distribution
is equivalent to a Disabled
150 %
bool = cellfun(@(c) isnan(c.paramValue), self.params)
151 bool = isnan(getMean(self));
154 function
bool = isImmediate(self)
155 % BOOL = ISIMMEDIATE()
156 % Check if the distribution
is equivalent to an Immediate
158 bool = self.immediate;
161 function
bool = isContinuous(self)
162 % BOOL = ISCONTINUOUS()
163 % Check if the distribution
is discrete
164 bool = isa(self,'ContinuousDistribution');
167 function
bool = isDiscrete(self)
168 % BOOL = ISDISCRETE()
169 % Check if the distribution
is discrete
170 bool = isa(self,'DiscreteDistribution');
173 function delta = evalProbInterval(self,t0,t1)
174 % DELTA = EVALPROBINTERVAL(SELF,T0,T1)
175 % Evaluate the probability mass between t0 and t1 (t1>t0)
177 Ft1 = self.evalCDF(t1);
178 Ft0 = self.evalCDF(t0);
181 line_error(mfilename,'CDF interval incorrectly specified (t1<t0)');