1classdef Uniform < ContinuousDistribution
2 % Uniform Continuous uniform distribution over a bounded interval
4 % Uniform represents the continuous uniform distribution with equal probability
5 % density over a specified interval [min, max]. This distribution models
6 % scenarios where all values within a range are equally likely, making it
7 % useful
for modeling bounded random processes with no preferred values.
9 % @brief Uniform distribution with equal probability over [min, max] interval
11 % Key characteristics:
12 % - Two parameters: minimum (min) and maximum (max) values
13 % - Mean = (min + max) / 2
14 % - Variance = (max - min)² / 12
15 % - Constant probability density over [min, max]
16 % - Support: [min, max]
18 % The uniform distribution
is used
for:
19 % - Modeling bounded processes with no bias
20 % - Random number generation in simulations
21 % - Representing equally likely outcomes
22 % - Initial parameter estimation
23 % - Load testing with uniform traffic patterns
27 % service_dist = Uniform(1.0, 3.0); % Service time between 1 and 3 units
28 % % Mean = 2.0, all values in [1.0, 3.0] equally likely
29 % samples = service_dist.sample(1000);
32 % Copyright (c) 2012-2026, Imperial College London
33 % All rights reserved.
36 function self = Uniform(minVal, maxVal)
37 % UNIFORM Create a Uniform distribution instance
39 % @brief Creates a Uniform distribution over the interval [minVal, maxVal]
40 % @param minVal Minimum value of the distribution support
41 % @param maxVal Maximum value of the distribution support (must be > minVal)
42 % @return self Uniform distribution instance
43 self@ContinuousDistribution('Uniform',2,[minVal,maxVal]);
44 setParam(self, 1,
'min', minVal);
45 setParam(self, 2,
'max', maxVal);
48 function ex = getMean(self)
51 % Get distribution mean
52 ex = (self.getParam(2).paramValue+self.getParam(1).paramValue) / 2;
55 function SCV = getSCV(self)
58 % Get distribution squared coefficient of variation (SCV = variance / mean^2)
59 var = (self.getParam(2).paramValue-self.getParam(1).paramValue)^2 / 12;
60 SCV = var/getMean(self)^2;
63 function Ft = evalCDF(self,t)
64 % FT = EVALCDF(SELF,T)
66 % Evaluate the cumulative distribution function at t
69 minVal = self.getParam(1).paramValue;
70 maxVal = self.getParam(2).paramValue;
76 Ft = 1/(maxVal-minVal);
80 function L = evalLST(self, s)
83 % Evaluate the Laplace-Stieltjes transform of the distribution function at t
85 minVal = self.getParam(1).paramValue;
86 maxVal = self.getParam(2).paramValue;
88 L = ( exp(-s*minVal) - exp(-s*maxVal) )/(s*(maxVal - minVal));
91 function X = sample(self, n)
94 % Get n samples from the distribution
95 if nargin<2 %~exist(
'n',
'var'),
98 minVal = self.getParam(1).paramValue;
99 maxVal = self.getParam(2).paramValue;
100 X = minVal + (maxVal-minVal)*rand(n,1);
103 function proc = getProcess(self)
104 % PROC = GETPROCESS()
106 % Get process representation with actual distribution parameters
107 % Returns {min, max}
for uniform distribution
108 proc = {self.getParam(1).paramValue, self.getParam(2).paramValue};