Home > wafo > wstats > wskewness.m

wskewness

PURPOSE ^

Computes sample skewness

SYNOPSIS ^

s = wskewness(X,dim)

DESCRIPTION ^

 WSKEWNESS Computes sample skewness
 
  CALL:  k = wskewness(X,dim);
 
         k = sample skewness (third central moment divided by second^(3/2))
         X = data vector or matrix
       dim = dimension to sum across. (default 1'st non-singleton 
                                               dimension of X)
 
  Example:
    R=wgumbrnd(2,2,[],100,2);
    wskewness(R)
 
  See also  wkurtosis, mean, var

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function s = wskewness(X,dim)
002 %WSKEWNESS Computes sample skewness
003 %
004 % CALL:  k = wskewness(X,dim);
005 %
006 %        k = sample skewness (third central moment divided by second^(3/2))
007 %        X = data vector or matrix
008 %      dim = dimension to sum across. (default 1'st non-singleton 
009 %                                              dimension of X)
010 %
011 % Example:
012 %   R=wgumbrnd(2,2,[],100,2);
013 %   wskewness(R)
014 %
015 % See also  wkurtosis, mean, var
016 
017 % Tested on: Matlab 5.3
018 % History:
019 % revised pab 24.10.2000
020 % - made it more general: accepts any size of X
021 % - added dim, nargchk
022 % added ms 16.06.2000
023 
024 error(nargchk(1,2,nargin))
025 sz = size(X);
026 if nargin<2|isempty(dim),
027   % Use 1'st non-singleton dimension or dimension 1
028   dim = min(find(sz~=1)); 
029   if isempty(dim), dim = 1; end
030 end
031 
032 rsz = ones(size(sz)); rsz(dim)=sz(dim);
033 mu  = mean(X,dim);
034 mu  = repmat(mu,rsz); % reshape mu to the size of X
035 s   = mean((X-mu).^3,dim)./mean((X-mu).^2,dim).^(3/2);
036 
037 
038 
039

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003