1classdef Normal < ContinuousDistribution
2 % Normal Normal (Gaussian) distribution
4 % Normal represents a normal (Gaussian) distribution with mean mu and
5 % standard deviation sigma. This distribution
is widely used in modeling
6 % continuous phenomena due to the central limit theorem.
8 % @brief Normal distribution with specified mean and standard deviation
10 % Key characteristics:
11 % - Two parameters: mean (mu) and standard deviation (sigma)
12 % - Variance = sigma^2
13 % - SCV = sigma^2 / mu^2
14 % - Support: (-Inf, Inf)
15 % - Symmetric with zero skewness
17 % Note: For queueing applications, a truncated or shifted version may
18 % be needed since normal distributions can take negative values.
22 % dist = Normal(5.0, 1.0); % Mean=5, StdDev=1
23 % samples = dist.sample(1000);
26 % Copyright (c) 2012-2026, Imperial College London
27 % All rights reserved.
30 function self = Normal(mu, sigma)
31 % NORMAL Create a Normal distribution instance
33 % @brief Creates a Normal distribution with specified mean and std dev
34 % @param mu Mean of the distribution
35 % @param sigma Standard deviation of the distribution (must be positive)
36 % @return self Normal distribution instance
37 self@ContinuousDistribution('Normal', 2, [-Inf, Inf]);
39 line_error(mfilename,
'sigma parameter must be >= 0.0');
41 setParam(self, 1,
'mu', mu);
42 setParam(self, 2,
'sigma', sigma);
45 function ex = getMean(self)
48 % Get distribution mean
49 ex = self.getParam(1).paramValue;
52 function SCV = getSCV(self)
55 % Get distribution squared coefficient of variation (SCV = variance / mean^2)
56 mu = self.getParam(1).paramValue;
57 sigma = self.getParam(2).paramValue;
58 if abs(mu) < GlobalConstants.FineTol
61 SCV = (sigma * sigma) / (mu * mu);
65 function VAR = getVar(self)
68 % Get distribution variance
69 sigma = self.getParam(2).paramValue;
73 function STD = getStd(self)
76 % Get distribution standard deviation
77 STD = self.getParam(2).paramValue;
80 function SKEW = getSkewness(self)
81 % SKEW = GETSKEWNESS()
83 % Get distribution skewness (always 0
for normal)
87 function Ft = evalCDF(self, t)
88 % FT = EVALCDF(SELF,T)
90 % Evaluate the cumulative distribution function at t
91 mu = self.getParam(1).paramValue;
92 sigma = self.getParam(2).paramValue;
93 Ft = 0.5 * (1 + erf((t - mu) / (sigma * sqrt(2))));
96 function L = evalLST(self, s)
99 % Evaluate the Laplace-Stieltjes transform of the distribution
100 % function at s: E[e^(-sX)] = exp(mu*s + 0.5*sigma^2*s^2)
101 % Note: this is the moment-generating function evaluated at -s
102 mu = self.getParam(1).paramValue;
103 sigma = self.getParam(2).paramValue;
104 L = exp(mu * s + 0.5 * sigma * sigma * s * s);
107 function X = sample(self, n)
110 % Get n samples from the distribution
114 mu = self.getParam(1).paramValue;
115 sigma = self.getParam(2).paramValue;
116 X = mu + sigma * randn(n, 1);
119 function proc = getProcess(self)
120 % PROC = GETPROCESS()
122 % Get process representation with actual distribution parameters
123 % Returns {mu, sigma}
for normal distribution
124 proc = {self.getParam(1).paramValue, self.getParam(2).paramValue};
129 function nm = fitMean(MEAN)
132 % Fit distribution with given mean and unit standard deviation
133 nm = Normal(MEAN, 1.0);
136 function nm = fitMeanAndStd(MEAN, STD)
137 % NM = FITMEANANDSTD(MEAN, STD)
139 % Fit distribution with given mean and standard deviation
140 nm = Normal(MEAN, max(GlobalConstants.FineTol, STD));
143 function nm = fitMeanAndVar(MEAN, VAR)
144 % NM = FITMEANANDVAR(MEAN, VAR)
146 % Fit distribution with given mean and variance
147 nm = Normal(MEAN, max(GlobalConstants.FineTol, sqrt(VAR)));
150 function nm = fitMeanAndSCV(MEAN, SCV)
151 % NM = FITMEANANDSCV(MEAN, SCV)
153 % Fit distribution with given mean and squared coefficient of
154 % variation (SCV = variance / mean^2)
156 nm = Normal(MEAN, max(GlobalConstants.FineTol, sqrt(VAR)));