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
% CHAPTER2 Modelling random loads and stochastic waves | |
Estimate transformation, g, from data. |
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
Comments or corrections to the WAFO group