skew2.m 478 B

123456789101112131415161718192021
  1. % S = SKEW2(MTX,MEAN,VAR)
  2. %
  3. % Sample skew (third moment divided by variance^3/2) of a matrix.
  4. % MEAN (optional) and VAR (optional) make the computation faster.
  5. function res = skew2(mtx, mn, v)
  6. if (exist('mn') ~= 1)
  7. mn = mean2(mtx);
  8. end
  9. if (exist('v') ~= 1)
  10. v = var2(mtx,mn);
  11. end
  12. if (isreal(mtx))
  13. res = mean(mean((mtx-mn).^3)) / (v^(3/2));
  14. else
  15. res = mean(mean(real(mtx-mn).^3)) / (real(v)^(3/2)) + ...
  16. i * mean(mean(imag(mtx-mn).^3)) / (imag(v)^(3/2));
  17. end