This is a static copy of a profile reportHome
ml_estcov (2 calls, 0.000 sec)
Generated 05-Nov-2014 07:52:30 using cpu time.
function in file /usr0/home/jenkins/workspace/cellorganizer-demo3D11-glnx64/utilities/3D/vesicles/ml_estcov.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
No measurable time spent in this functionLine Number | Code | Calls | Total Time | % Time | Time Plot |
89 | sig = ml_estcov(x,param); | 1 | 0 s | 0% |  |
88 | param.method = 'free'; | 1 | 0 s | 0% |  |
87 | param.flag = 1; | 1 | 0 s | 0% |  |
86 | case 'mle' | 1 | 0 s | 0% |  |
81 | if p>0 %if the covariance m... | 1 | 0 s | 0% |  |
All other lines | | | 0 s | 0% |  |
Totals | | | 0 s | 0% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
ml_cov | function | 1 | 0 s | 0% |  |
ml_estcov | function | 1 | 0 s | 0% |  |
ml_initparam | function | 2 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 0 s | 0% |  |
Totals | | | 0 s | 0% | |
Code Analyzer results
Line number | Message |
60 | The first argument of WARNING should be a message identifier. Using a message identifier allows users better control over the message. |
80 | The value assigned here to 'R' appears to be unused. Consider replacing it by ~. |
82 | The first argument of WARNING should be a message identifier. Using a message identifier allows users better control over the message. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 114 |
Non-code lines (comments, blank lines) | 70 |
Code lines (lines that can run) | 44 |
Code lines that did run | 14 |
Code lines that did not run | 30 |
Coverage (did run/can run) | 31.82 % |
Function listing
time calls line
1 function sig = ml_estcov(x,param)
2 %ML_ESTCOV Covariance matrix estimation.
3 % SIG = ML_ESTCOV(X) returns a covariace matrix estimated from the
4 % [feature matrix] X.
5 %
6 % SIG = ML_ESTCOV(X,PARAM) specifies how to calculate the covariance
7 % matrix. PARAM has the following fields:
8 % 'method' - method of estimating covariance matrix
9 % 'mle' - maximum likelihood estimation
10 % 'ind' - diagonal covariance matrix. This assumes that all
11 % variables are independent.
12 % 'idv' - This assumes that all variables are independent and
13 % have identical variance.
14 % 'weights' - a colum vector for specifying the weights of the data
15 % points. It must have as many as rows as X. The ith element is
16 % the weight for the ith row in X.
17 % 'calscale' - this is to calibrate the diagonal elements of the
18 % covariance matrix is it is not positive definite. The defaut
19 % value is 0.01.
20 % 'mu' - predefined mean of X. If it is empty or not exist, the mean
21 % will be calculated from X.
22 %
23 % See also
24
25 % 16-Jun-2006 Initial write T. Zhao
26 % Copyright (c) 2006 Murphy Lab
27 % Carnegie Mellon University
28 %
29 % This program is free software; you can redistribute it and/or modify
30 % it under the terms of the GNU General Public License as published
31 % by the Free Software Foundation; either version 2 of the License,
32 % or (at your option) any later version.
33 %
34 % This program is distributed in the hope that it will be useful, but
35 % WITHOUT ANY WARRANTY; without even the implied warranty of
36 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
37 % General Public License for more details.
38 %
39 % You should have received a copy of the GNU General Public License
40 % along with this program; if not, write to the Free Software
41 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
42 % 02110-1301, USA.
43 %
44 % For additional information visit http://murphylab.web.cmu.edu or
45 % send email to murphy@cmu.edu
46
47
2 48 if nargin < 1
49 error('1 or 2 arguments are required')
50 end
51
2 52 if ~exist('param','var')
53 param = struct([]);
54 end
55
2 56 param = ml_initparam(param, ...
57 struct('method','mle','weights',[],'calscale',0.01,'mu',[],'flag',1));
58
2 59 if size(x,1)==1
60 warning(['There is only one sample for ' ...
61 'covariance matrix estimation']);
62 sig = 0;
63 return;
64 end
65
2 66 if isempty(param.mu)
67 if ~isempty(param.weights)
68 for i=1:size(x,2)
69 param.mu(i) = ml_wmoment(x(:,i),param.weights,1);
70 end
71 else
72 param.mu = mean(x,1);
73 end
74
75 end
76
2 77 switch param.method
2 78 case 'free'
1 79 sig = ml_cov(x,param.flag,param.weights,param.mu);
1 80 [R,p] = chol(sig);
1 81 if p>0 %if the covariance matrix is not positive definite
82 warning(['The covariance matrix is not ' ...
83 'positive definite. Calibration is done.']);
84 sig = sig+diag(diag(sig)*param.calscale);
85 end
1 86 case 'mle'
1 87 param.flag = 1;
1 88 param.method = 'free';
1 89 sig = ml_estcov(x,param);
90
91 case 'ind'
92 sig = ml_cov(x,param.flag,param.weights,param.mu);
93 sig = diag(diag(sig));
94 % if isempty(param.weights)
95 % sig = diag(var(x,1,1));
96 % else
97 % for i=1:size(x,2)
98 % sig(i,i) = ml_wmoment(x(:,i),param.weights,2);
99 % end
100 % end
101 case {'idv','iid'}
102 % n = size(x,1);
103 k = size(x,2);
104 % if isempty(param.weights)
105 % v = sum(var(x,1,1))/k;
106 % else
107 % v = ml_wmoment(x(:),repmat(param.weights,k,1),2);
108 % end
109 x = ml_addrow(x,-param.mu);
110 v = ml_cov(x(:),param.flag,repmat(param.weights,k,1),0);
111 sig = diag(zeros(1,k)+v);
112 otherwise
113 error('Unrecognized covariance estimation method.');
114 end