function [statistics] = ... 
    computeStatistics ( pvErr, segments, errType, statistics );

meanErr = mean( pvErr );
stdErr = std( pvErr );

for segIdx = 1:length(segments.segList)
  pvSeg = pvErr(segments.segList{segIdx},:);
  meanSegErr{segIdx} = mean(pvSeg);
  stdSegErr{segIdx} = std(pvSeg);
end

% Populate statistics structure
if strcmp( errType, 'velocity' )
  statistics.meanVelErr = meanErr;
  statistics.stdVelErr = stdErr; 
  statistics.meanVelErrBySeg = meanSegErr;
  statistics.stdVelErrBySeg = stdSegErr;
else  
  statistics.meanPosErr = meanErr;
  statistics.stdPosErr = stdErr; 
  statistics.meanPosErrBySeg = meanSegErr;
  statistics.stdPosErrBySeg = stdSegErr;
end

end
