LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Replayer.m
1classdef Replayer < Distribution
2 % Empirical time series from a trace
3 %
4 % Copyright (c) 2012-2026, Imperial College London
5 % All rights reserved.
6
7 properties
8 data;
9 cursample;
10 end
11
12 methods
13 %Constructor
14 function self = Replayer(data)
15 self@Distribution('Replayer',1,[0,Inf]);
16 if ischar(data) % interpret as string
17 % SELF = REPLAYER(FILENAME)
18 fileName = data;
19 if exist(fileName,'file') == 2
20 dirStruct = dir(fileName);
21 fileName = [dirStruct.folder,filesep,dirStruct.name];
22 else
23 line_error(mfilename,'The file cannot be located, use the full file path.');
24 end
25 setParam(self, 1, 'fileName', fileName);
26 self.data = [];
27 % Create Java object after file validation with validated path
28 self.obj = jline.lang.processes.Replayer(fileName);
29 else
30 self.data = data;
31 self.cursample = 0;
32 % Create Java object directly with array data
33 self.obj = jline.lang.processes.Replayer(data);
34 end
35 end
36
37 function load(self)
38 % LOAD()
39
40 fileName = self.getParam(1).paramValue;
41 self.data = load(fileName);
42 self.data = self.data(:);
43 self.cursample = 0;
44 end
45
46 function unload(self)
47 % UNLOAD()
48
49 self.data = [];
50 end
51
52 function rate = getRate(self)
53 rate = 1 / self.getMean;
54 end
55
56 function ex = getMean(self)
57 % EX = GETMEAN()
58
59 % Get distribution mean
60 if isempty(self.data)
61 self.load();
62 end
63 ex = mean(self.data);
64 end
65
66 function SCV = getSCV(self)
67 % SCV = GETSCV()
68
69 % Get distribution squared coefficient of variation (SCV = variance / mean^2)
70 if isempty(self.data)
71 self.load();
72 end
73 SCV = var(self.data)/mean(self.data)^2;
74 end
75
76 function SKEW = getSkewness(self)
77 % SKEW = GETSKEWNESS()
78
79 % Get distribution skewness
80 if isempty(self.data)
81 load(self);
82 end
83 SKEW = skewness(self.data,0); % ,0 ensures Apache Commons equivalence in Java
84 end
85
86 function distr = fitExp(self)
87 % DISTR = FITEXP()
88
89 distr = Exp.fitMean(self.getMean);
90 end
91
92 function distr = fitAPH(self)
93 % DISTR = FITAPH()
94 distr = APH.fit(self.getMean, self.getSCV, self.getSkewness);
95 distr.obj = self.obj.fitAPH();
96 end
97
98 function distr = fitCoxian(self)
99 % DISTR = FITCOXIAN()
100 distr = Cox2.fit(self.getMean, self.getSCV, self.getSkewness);
101
102 end
103
104 function X = sample(self)
105 % X = SAMPLE()
106 self.cursample = self.cursample + 1;
107 X = self.data(self.cursample);
108 end
109
110 function L = evalLST(self, s)
111 % L = EVALST(S)
112 % Evaluate the Laplace-Stieltjes transform of the distribution function at t
113 if isempty(self.data)
114 self.load();
115 end
116 L = mean(exp(-s*self.data));
117 end
118 end
119end
120