LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Uniform.m
1classdef Uniform < ContinuousDistribution
2 % Uniform Continuous uniform distribution over a bounded interval
3 %
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.
8 %
9 % @brief Uniform distribution with equal probability over [min, max] interval
10 %
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]
17 %
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
24 %
25 % Example:
26 % @code
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);
30 % @endcode
31 %
32 % Copyright (c) 2012-2026, Imperial College London
33 % All rights reserved.
34
35 methods
36 function self = Uniform(minVal, maxVal)
37 % UNIFORM Create a Uniform distribution instance
38 %
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);
46 end
47
48 function ex = getMean(self)
49 % EX = GETMEAN()
50
51 % Get distribution mean
52 ex = (self.getParam(2).paramValue+self.getParam(1).paramValue) / 2;
53 end
54
55 function SCV = getSCV(self)
56 % SCV = GETSCV()
57
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;
61 end
62
63 function Ft = evalCDF(self,t)
64 % FT = EVALCDF(SELF,T)
65
66 % Evaluate the cumulative distribution function at t
67 % AT T
68
69 minVal = self.getParam(1).paramValue;
70 maxVal = self.getParam(2).paramValue;
71 if t < minVal
72 Ft = 0;
73 elseif t > maxVal
74 Ft = 0;
75 else
76 Ft = 1/(maxVal-minVal);
77 end
78 end
79
80 function L = evalLST(self, s)
81 % L = EVALST(S)
82
83 % Evaluate the Laplace-Stieltjes transform of the distribution function at t
84
85 minVal = self.getParam(1).paramValue;
86 maxVal = self.getParam(2).paramValue;
87
88 L = ( exp(-s*minVal) - exp(-s*maxVal) )/(s*(maxVal - minVal));
89 end
90
91 function X = sample(self, n)
92 % X = SAMPLE(N)
93
94 % Get n samples from the distribution
95 if nargin<2 %~exist('n','var'),
96 n = 1;
97 end
98 minVal = self.getParam(1).paramValue;
99 maxVal = self.getParam(2).paramValue;
100 X = minVal + (maxVal-minVal)*rand(n,1);
101 end
102
103 function proc = getProcess(self)
104 % PROC = GETPROCESS()
105
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};
109 end
110 end
111
112end
113