Home > custom > colfilt_filters > smooth_2std_mean.m

smooth_2std_mean

PURPOSE ^

PURPOSE: colfilt function to smooth outliers > 2x StdDev to mean

SYNOPSIS ^

function [r] = smooth_2std_mean(X)

DESCRIPTION ^

 PURPOSE: colfilt function to smooth outliers > 2x StdDev to mean
          if absolute value of center cell is more than the 2x standard deviation  
          above the mean of its neighbourhood, the mean of this neighbourhood
          is assigned to it instead, otherwise value remains unchanged.

 See also: colfilt

 Felix Hebeler, Geography Dept., University Zurich, August 2006.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [r] = smooth_2std_mean(X)
0002 % PURPOSE: colfilt function to smooth outliers > 2x StdDev to mean
0003 %          if absolute value of center cell is more than the 2x standard deviation
0004 %          above the mean of its neighbourhood, the mean of this neighbourhood
0005 %          is assigned to it instead, otherwise value remains unchanged.
0006 %
0007 % See also: colfilt
0008 %
0009 % Felix Hebeler, Geography Dept., University Zurich, August 2006.
0010 
0011 r=X(ceil(size(X,1)/2),:);  % value at center of neighbourhood
0012 c=abs(r-nanmean(X))-2*nanstd(X); % criterion
0013 v=nanmean(X);                    % new value
0014 r(c>0)=v(c>0);
0015

Generated on Tue 24-Feb-2009 19:14:50 by m2html © 2003