Home > bml > utils > bml_robust_std.m

bml_robust_std

PURPOSE ^

BML_ROBUST_STD calculates a row-wise robust estimation of the standard deviation

SYNOPSIS ^

function std = bml_robust_std(data, center)

DESCRIPTION ^

 BML_ROBUST_STD calculates a row-wise robust estimation of the standard deviation

 Use as
   std = robust_std(data, center)
   std = robust_std(vector)

 data - double: row vector or matrix on which to calculate the robust std
   if data is a matrix, the centering is done by row. 
 center - double: center of the distribution. Defaults to median(data) 
   if data is a matrix, center has to be a column vector of the same
   height as data

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function std = bml_robust_std(data, center)
0002 
0003 % BML_ROBUST_STD calculates a row-wise robust estimation of the standard deviation
0004 %
0005 % Use as
0006 %   std = robust_std(data, center)
0007 %   std = robust_std(vector)
0008 %
0009 % data - double: row vector or matrix on which to calculate the robust std
0010 %   if data is a matrix, the centering is done by row.
0011 % center - double: center of the distribution. Defaults to median(data)
0012 %   if data is a matrix, center has to be a column vector of the same
0013 %   height as data
0014 
0015 if nargin==1
0016   center = median(data,2);
0017 end
0018 
0019 std = zeros(size(data,1),1);
0020 
0021 for i=1:size(data,1)
0022   s=quantile(abs(data(i,:)),0.95);
0023   p=0.5;
0024   while std(i) < 1e4*eps(s) && p < 1
0025     std(i)=quantile(abs(data(i,:) - center(i)),p)/norminv((1+p)/2);
0026     p = p + 0.05;
0027   end
0028   if std(i) < 1e4*eps(s)
0029     std(i)=0;
0030   end
0031 end

Generated on Tue 25-Sep-2018 10:08:19 by m2html © 2005