comparison m-toolbox/classes/@stattest/stattest.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % STATTEST constructor for stattest class.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: STATTEST constructor for stattest class.
5 %
6 % CONSTRUCTOR:
7 %
8 % st = stattest() - creates an empty stattest object
9 % st = stattest(ao,ao,...) - creates a stattest with the given data
10 % st = stattest(ao,ao,..., pl) - creates a stattest with the given data
11 %
12 % <a href="matlab:utils.helper.displayMethodInfo('stattest', 'stattest')">Parameters Description</a>
13 %
14 % VERSION: $Id: stattest.m,v 1.6 2011/04/08 08:56:38 hewitson Exp $
15 %
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
18 classdef stattest < ltpda_uoh
19
20 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21 % Property definition %
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23
24 %---------- Public (read/write) Properties ----------
25 properties
26 end
27
28 %---------- Protected read-only Properties ----------
29 properties (SetAccess = protected)
30 data = {}; % The data vector of ltpda user objects
31 result = false; % Store the result of the last test performed
32 pvalue = [];
33 end
34
35 %---------- Private Properties ----------
36 properties (GetAccess = protected, SetAccess = protected)
37 end
38
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 % Check property setting %
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42
43 methods
44 %--- expr
45 function obj = set.data(obj, val)
46 if isempty(val)
47 obj.data = {};
48 return;
49 end
50 if numel(val)==1 && isa(val, 'ltpda_uoh')
51 obj.data = val;
52 return;
53 end
54 if iscell(val)
55 % check each element
56 newdata = [];
57 for ll=1:numel(val)
58 if isa(val{ll}, 'ltpda_uoh')
59 newdata = [newdata val(ll)];
60 end
61 end
62 obj.data = newdata;
63 return;
64 end
65 error('### The data array should contain only ltpda user objects');
66 end
67 %--- params
68 function obj = set.result(obj, val)
69 if ~islogical(val)
70 error('### The result should be a logical (true/false)');
71 end
72 obj.result = val;
73 end
74 %--- values
75 function obj = set.pvalue(obj, val)
76 if ~isnumeric(val)
77 error('### The pvalue must be numeric');
78 end
79 obj.pvalue = val;
80 end
81 end
82
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 % Constructor %
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86
87 methods
88 function obj = stattest(varargin)
89
90 import utils.const.*
91 utils.helper.msg(msg.OMNAME, 'running %s/%s', mfilename('class'), mfilename);
92
93 % Collect all stattest objects
94 [sts, invars, rest] = utils.helper.collect_objects(varargin(:), 'stattest');
95
96 if isempty(rest) && ~isempty(sts)
97 % Do copy constructor and return
98 utils.helper.msg(msg.OPROC1, 'copy constructor');
99 obj = copy(sts, 1);
100 for kk=1:numel(obj)
101 obj(kk).addHistory(smodel.getInfo('stattest', 'None'), [], [], obj(kk).hist);
102 end
103 return
104 end
105
106 switch nargin
107 case 0
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109 %%%%%%%%%%%%%%%%%%%%%%%%%%%% no input %%%%%%%%%%%%%%%%%%%%%%%%%%%*
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111 utils.helper.msg(msg.OPROC1, 'empty constructor');
112 obj.addHistory(stattest.getInfo('stattest', 'None'), plist(), [], []);
113
114 case 1
115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 %%%%%%%%%%%%%%%%%%%%%%%%%%% One input %%%%%%%%%%%%%%%%%%%%%%%%%%%
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 if ischar(varargin{1})
119 %%%%%%%%%% mdl = stattest('foo.mat') %%%%%%%%%%
120 %%%%%%%%%% mdl = stattest('foo.xml') %%%%%%%%%%
121
122 % Is this a file?
123 [path, name, ext] = fileparts(varargin{1});
124
125 if ismember(ext, {'.xml', '.mat', '.txt', '.dat', '.fil'})
126 utils.helper.msg(msg.OPROC1, 'constructing from file %s', varargin{1});
127 obj = obj.fromFile(varargin{1});
128 else
129 error('Unknown file extension %s', ext);
130 end
131
132 elseif isa(varargin{1}, 'ltpda_uoh')
133 %%%%%%%%%% st = stattest(ltpda_objects) %%%%%%%%%%
134 utils.helper.msg(msg.OPROC1, 'constructing from ltpda objects');
135 obj.data = varargin{1};
136
137 elseif iscell(varargin{1})
138 %%%%%%%%%% st = stattest({a,b,c}) %%%%%%%%%%
139
140 pl = plist('data', varargin{1});
141 obj = obj.fromData(pl);
142
143
144 elseif isa(varargin{1}, 'plist')
145 %%%%%%%%%% st = stattest(plist-object) %%%%%%%%%%
146
147 pl = varargin{1};
148
149 if pl.isparam('data')
150 utils.helper.msg(msg.OPROC1, 'constructing from data');
151 obj = obj.fromData(pl);
152
153 else
154 obj.setProperties(pl);
155 obj.addHistory(stattest.getInfo('stattest', 'None'), pl, [], []);
156 end
157
158 else
159 error('### Unknown single argument constructor.');
160 end
161 case 2
162
163 if isa(varargin{1}, 'org.apache.xerces.dom.DeferredElementImpl') && ...
164 isa(varargin{2}, 'history')
165 %%%%%%%%%% obj = ao(DOM node, history-objects) %%%%%%%%%%
166 obj = fromDom(obj, varargin{1}, varargin{2});
167 else
168 error('### Unknown constructor with two inputs');
169 end
170 otherwise
171 [objs, invars, rest] = utils.helper.collect_objects(varargin, 'ltpda_uoh');
172 [pls, invars, rest] = utils.helper.collect_objects(varargin, 'plist');
173 pl = combine(pls, stattest.getDefaultPlist('From Data'));
174 pl.pset('data', objs);
175 obj = obj.fromData(pl);
176
177 end
178
179 end % End constructor
180
181 end
182
183 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
184 % Methods (protected) %
185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186 methods (Access = protected)
187 end
188
189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190 % Methods (static) %
191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
192 methods (Static)
193
194 function sts = getBuiltInModels(varargin)
195 sts = ltpda_uo.getBuiltInModels('stattest');
196 end
197
198 function out = VEROUT()
199 out = '$Id: stattest.m,v 1.6 2011/04/08 08:56:38 hewitson Exp $';
200 end
201
202 function ii = getInfo(varargin)
203 ii = utils.helper.generic_getInfo(varargin{:}, 'stattest');
204 end
205
206 function out = SETS()
207 out = [SETS@ltpda_uoh, ...
208 {'Default'}, ...
209 {'From Data'}...
210 ];
211 end
212
213
214 function plout = getDefaultPlist(set)
215 persistent pl;
216 persistent lastset;
217 if exist('pl', 'var')==0 || isempty(pl) || ~strcmp(lastset, set)
218 pl = stattest.buildplist(set);
219 lastset = set;
220 end
221 plout = pl;
222 end
223
224 function out = buildplist(set)
225
226 if ~utils.helper.ismember(lower(stattest.SETS), lower(set))
227 error('### Unknown set [%s]', set);
228 end
229
230 out = plist();
231 out = stattest.addGlobalKeys(out);
232 out = buildplist@ltpda_uoh(out, set);
233
234 switch lower(set)
235 case 'from data'
236
237 % Expression
238 p = param({'data','Array of LTPDA user objects to set as the data.'}, paramValue.EMPTY_DOUBLE);
239 out.append(p);
240
241 end
242 end % function out = getDefaultPlist(varargin)
243
244 function obj = initObjectWithSize(n,m)
245 obj = stattest.newarray([n m]);
246 for ii = 1:numel(obj)
247 obj(ii).UUID = char(java.util.UUID.randomUUID);
248 end
249 end
250
251 end % End static methods
252
253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254 % Methods (static, private) %
255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256
257 methods (Static, Access=private)
258 varargout = elementOp(varargin)
259 end % End static, private methods
260
261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
262 % Methods (static, hidden) %
263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
264
265 methods (Static = true, Hidden = true)
266 varargout = loadobj(varargin)
267 varargout = update_struct(varargin);
268 end
269
270 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271 % Methods (public) %
272 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
273 methods
274 varargout = char(varargin)
275 varargout = display(varargin)
276 varargout = copy(varargin)
277
278 varargout = setData(varargin)
279
280 end
281
282 methods (Hidden = true)
283 varargout = attachToDom(varargin)
284 end
285
286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 % Methods (protected) %
288 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
289 methods (Access = protected)
290 varargout = fromStruct(varargin)
291 varargout = fromDom(varargin)
292 end
293
294 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
295 % Methods (private) %
296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
297 methods (Access = private)
298 end
299
300 end % End classdef
301