function [mu V S K]=stats(x)

if nargin==1, 
  % Determine which dimension SUM will use
  dim = min(find(size(x)~=1));
  if isempty(dim) 
    dim = 1; 
  end
  N=size(x,dim);
  mu=sum(x)/N;
  xz=x-mu;
  V=sum(xz.^2)/(N-1);
  S=sum(xz.^3)/V/sqrt(V)/(N-1);
  K=sum(xz.^4)/V^2/(N-1);
else
  mu = sum(x,dim)/size(x,dim);
  xz=x-mu;
  V=sum(xz.^2,dim)/(N-1);
  S=sum(xz.^3,dim)/V/sqrt(V)/(N-1);
  K=sum(xz.^4,dim)/V^2/(N-1);
end
