comparison m-toolbox/classes/@ao/ecdf.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 % ECDF calculate empirical cumulative distribution function
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % Description:
4 %
5 % ECDF calculate empirical cumulative distribution function
6 %
7 % CALL: b = ecdf(a, pl)
8 %
9 % INPUT: a: are real valued AO.
10 %
11 % OUTPUT: b: Empirical cumulative distribution
12 %
13 %
14 %
15 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'ecdf')">Parameters Description</a>
16 %
17 % VERSION: $Id: ecdf.m,v 1.2 2011/07/08 13:13:14 luigi Exp $
18 %
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20
21 function varargout = ecdf(varargin)
22
23 % Check if this is a call for parameters
24 if utils.helper.isinfocall(varargin{:})
25 varargout{1} = getInfo(varargin{3});
26 return
27 end
28
29 import utils.const.*
30 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
31
32 % Collect input variable names
33 in_names = cell(size(varargin));
34 for ii = 1:nargin,in_names{ii} = inputname(ii);end
35
36 % Collect all AOs and plists
37 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
38
39 if nargout == 0
40 error('### ECDF cannot be used as a modifier. Please provide an output variable.');
41 end
42
43
44 % Collect input histories
45 inhists = [as.hist];
46
47 % Apply defaults to plist
48 pl = applyDefaults(getDefaultPlist, varargin{:});
49
50 bs = ao.initObjectWithSize(1, numel(as));
51 % run over input aos
52 for ii=1:numel(bs)
53
54 [F,X] = utils.math.ecdf(as(ii).y);
55
56 bs(ii) = ao(plist('xvals', X, 'yvals', F));
57 bs(ii).setName(sprintf('ECDF(%s)', as(ii).name));
58 bs(ii).addHistory(getInfo('None'), pl, ao_invars(ii), inhists(ii));
59 end
60
61 % Set output
62 varargout = utils.helper.setoutputs(nargout, bs);
63
64 end
65
66
67 %--------------------------------------------------------------------------
68 % Get Info Object
69 %--------------------------------------------------------------------------
70 function ii = getInfo(varargin)
71 if nargin == 1 && strcmpi(varargin{1}, 'None')
72 sets = {};
73 pl = [];
74 else
75 sets = {'Default'};
76 pl = getDefaultPlist();
77 end
78 % Build info object
79 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.sigproc, '$Id: ecdf.m,v 1.2 2011/07/08 13:13:14 luigi Exp $', sets, pl);
80 end
81
82 %--------------------------------------------------------------------------
83 % Get Default Plist
84 %--------------------------------------------------------------------------
85 function plout = getDefaultPlist()
86 persistent pl;
87 if ~exist('pl', 'var') || isempty(pl)
88 pl = buildplist();
89 end
90 plout = pl;
91 end
92
93 function plo = buildplist()
94 plo = plist();
95
96
97 end