This is a static copy of a profile reportHome
ml_cov (1 call, 0.000 sec)
Generated 05-Nov-2014 07:52:41 using cpu time.
function in file /usr0/home/jenkins/workspace/cellorganizer-demo3D11-glnx64/utilities/2D/tztoolbox/ml_cov.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
ml_estcov | function | 1 |
Lines where the most time was spent
No measurable time spent in this functionLine Number | Code | Calls | Total Time | % Time | Time Plot |
105 | end | 1 | 0 s | 0% |  |
101 | xy = wxc' * xc / m; | 1 | 0 s | 0% |  |
100 | if flag | 1 | 0 s | 0% |  |
98 | wxc=xc; | 1 | 0 s | 0% |  |
94 | xc = wx - repmat(xbar,m,1); %... | 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 |
repmat | function | 1 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 0 s | 0% |  |
Totals | | | 0 s | 0% | |
Code Analyzer results
Line number | Message |
71 | NUMEL(x) is usually faster than PROD(SIZE(x)). |
75 | The value assigned to variable 'n' might be unused. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 105 |
Non-code lines (comments, blank lines) | 63 |
Code lines (lines that can run) | 42 |
Code lines that did run | 26 |
Code lines that did not run | 16 |
Coverage (did run/can run) | 61.90 % |
Function listing
time calls line
1 function xy = ml_cov(x,varargin)
2 %ML_COV Covariance matrix. (Modified from Matlab COV funcion)
3 % ML_COV(X), if X is a vector, returns the variance. For matrices,
4 % where each row is an observation, and each column a variable,
5 % ML_COV(X) is the covariance matrix. DIAG(ML_COV(X)) is a vector of
6 % variances for each column, and SQRT(DIAG(ML_COV(X))) is a vector
7 % of standard deviations.
8 %
9 % ML_COV(X) onormalizes by (N-1) where N is the number of
10 % observations. This makes ML_COV(X) the best unbiased estimate of the
11 % covariance matrix if the observations are from a normal distribution.
12 %
13 % ML_COV(X,1) normalizes by N and produces the second
14 % moment matrix of the observations about their mean. ML_COV(X,Y,0) is
15 % the same as ML_COV(X,Y) and ML_COV(X,0) is the same as ML_COV(X).
16 %
17 % ML_COV(X,FLAG,WEIGHTS) calculate weighted covariance matrix.
18 %
19 % ML_COV(X,FLAG,WEIGHTS,MU) calculate the covariance matrix based on the
20 % predefined mean MU.
21 %
22 % The mean is removed from each column before calculating the
23 % result.
24 %
25 % See also CORRCOEF, STD, MEAN.
26
27 % J. Little 5-5-86
28 % Revised 6-9-88 LS 3-10-94 BJ
29 % Copyright 1984-2001 The MathWorks, Inc.
30 % $Revision: 1.2 $ $Date: 2006/11/17 19:11:38 $
31
32 % Copyright (C) 2007 Murphy Lab
33 % Carnegie Mellon University
34 %
35 % This program is free software; you can redistribute it and/or modify
36 % it under the terms of the GNU General Public License as published
37 % by the Free Software Foundation; either version 2 of the License,
38 % or (at your option) any later version.
39 %
40 % This program is distributed in the hope that it will be useful, but
41 % WITHOUT ANY WARRANTY; without even the implied warranty of
42 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43 % General Public License for more details.
44 %
45 % You should have received a copy of the GNU General Public License
46 % along with this program; if not, write to the Free Software
47 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
48 % 02110-1301, USA.
49 %
50 % For additional information visit http://murphylab.web.cmu.edu or
51 % send email to murphy@cmu.edu
52
1 53 if nargin==0, error('Not enough input arguments.'); end
1 54 if nargin>4, error('Too many input arguments.'); end
1 55 if ndims(x)>2, error('Inputs must be 2-D.'); end
56
1 57 nin = nargin;
1 58 if nin>2
1 59 flag=varargin{1};
60 else
61 flag=0;
62 end
63
1 64 if nin==3
65 weights=varargin{2};
1 66 else
1 67 weights=[];
1 68 end
69
70
1 71 if length(x)==prod(size(x))
72 x = x(:);
73 end
74
1 75 [m,n] = size(x);
76
1 77 if m==1, % Handle special case
78 xy = 0;
1 79 else
1 80 if ~isempty(weights)
81 wx=repmat(weights,1,size(x,2)).*x*m/sum(weights);
1 82 else
1 83 wx=x;
1 84 end
1 85 if nin==4
1 86 xbar = varargin{3};
87 else
88 xbar = [];
89 end
1 90 if isempty(xbar)
91 xbar=mean(wx,1);
92 end
93
1 94 xc = wx - repmat(xbar,m,1); % Remove mean
95 % if ~isempty(weights)
96 % wxc=diag(weights)*xc;
97 % else
1 98 wxc=xc;
99 % end
1 100 if flag
1 101 xy = wxc' * xc / m;
102 else
103 xy = wxc' * xc / (m-1);
104 end
1 105 end
Other subfunctions in this file are not included in this listing.