This is a static copy of a profile report

Home

skewness (6058 calls, 6.359 sec)
Generated 05-Nov-2014 07:52:41 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/stats/stats/skewness.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ml_bwmajoranglefunction6058
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
41
m3 = nanmean(x0.^3,dim);
60583.795 s59.7%
39
x0 = x - repmat(nanmean(x,dim)...
60581.302 s20.5%
40
s2 = nanmean(x0.^2,dim); % thi...
60580.691 s10.9%
29
dim = find(size(x) ~= 1, 1);
60580.090 s1.4%
45
if flag == 0
60580.070 s1.1%
All other lines  0.411 s6.5%
Totals  6.359 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
nanmeanfunction181741.302 s20.5%
repmatfunction60580.651 s10.2%
Self time (built-ins, overhead, etc.)  4.406 s69.3%
Totals  6.359 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in function49
Non-code lines (comments, blank lines)30
Code lines (lines that can run)19
Code lines that did run15
Code lines that did not run4
Coverage (did run/can run)78.95 %
Function listing
   time   calls  line
1 function s = skewness(x,flag,dim)
2 %SKEWNESS Skewness.
3 % S = SKEWNESS(X) returns the sample skewness of the values in X. For a
4 % vector input, S is the third central moment of X, divided by the cube
5 % of its standard deviation. For a matrix input, S is a row vector
6 % containing the sample skewness of each column of X. For N-D arrays,
7 % SKEWNESS operates along the first non-singleton dimension.
8 %
9 % SKEWNESS(X,0) adjusts the skewness for bias. SKEWNESS(X,1) is the same
10 % as SKEWNESS(X), and does not adjust for bias.
11 %
12 % SKEWNESS(X,FLAG,DIM) takes the skewness along dimension DIM of X.
13 %
14 % SKEWNESS treats NaNs as missing values, and removes them.
15 %
16 % See also MEAN, MOMENT, STD, VAR, KURTOSIS.
17
18 % Copyright 1993-2004 The MathWorks, Inc.
19 % $Revision: 1.1.6.1 $ $Date: 2010/03/16 00:17:32 $
20
0.01 6058 21 if nargin < 2 || isempty(flag)
0.01 6058 22 flag = 1;
0.01 6058 23 end
0.02 6058 24 if nargin < 3 || isempty(dim)
25 % The output size for [] is a special case, handle it here.
0.07 6058 26 if isequal(x,[]), s = NaN; return; end;
27
28 % Figure out which dimension nanmean will work along.
0.09 6058 29 dim = find(size(x) ~= 1, 1);
0.02 6058 30 if isempty(dim), dim = 1; end
0.03 6058 31 end
32
33 % Need to tile the output of nanmean to center X.
0.03 6058 34 tile = ones(1,max(ndims(x),dim));
0.05 6058 35 tile(dim) = size(x,dim);
36
37 % Center X, compute its third and second moments, and compute the
38 % uncorrected skewness.
1.30 6058 39 x0 = x - repmat(nanmean(x,dim), tile);
0.69 6058 40 s2 = nanmean(x0.^2,dim); % this is the biased variance estimator
3.80 6058 41 m3 = nanmean(x0.^3,dim);
0.03 6058 42 s = m3 ./ s2.^(1.5);
43
44 % Bias correct the skewness.
0.07 6058 45 if flag == 0
46 n = sum(~isnan(x),dim);
47 n(n<3) = NaN; % bias correction is not defined for n < 3.
48 s = s .* sqrt((n-1)./n) .* n./(n-2);
49 end