remove outliers -凯发k8网页登录

main content

remove outliers

remove outliers interactively

to remove outliers in the curve fitter app, follow these steps:

  1. in the plot axes toolbar, click the exclude outliers button .

    when you move the mouse cursor to the plot, it changes to a cross-hair to show that you are in outlier selection mode.

  2. click a point that you want to exclude in the fit plot or residuals plot. alternatively, click and drag to define a rectangle and remove all enclosed points.

    a removed plot point becomes a red cross in the plots. if you have auto fitting selected in the fit section of the curve fitter tab, the curve fitter app refits the surface without the point. otherwise, if you have manual fitting selected, you can click fit to refit.

  3. repeat the process for all points you want to exclude.

when removing outliers from surface fits, it can be helpful to display a 2-d residuals plot for examining and removing outliers. with your plot cursor in rotation mode, right-click the plot to select go to x-y view, go to x-z view, or go to y-z view.

to replace individual excluded points in the fit, click an excluded point again in outlier selection mode (that is, with the exclude outliers button toggled on in the axes toolbar). to replace all excluded points in the fit, right-click and select clear all exclusions.

in surface plots, to return to rotation mode, click the exclude outliers button again to turn off outlier selection mode.

exclude data ranges

to exclude sections of data by range in the curve fitter app, follow these steps:

  1. on the curve fitter tab, in the data section, click exclusion rules.

  2. in the exclusion rules dialog box, specify data to exclude. enter numbers in any of the boxes to define beginning or ending intervals to exclude in the x, y, or z data.

    the curve fitter app displays shaded pink areas on the plots to show excluded ranges. excluded points become red.

remove outliers programmatically

this example shows how to remove outliers when curve fitting programmatically, using the 'exclude' name/value pair argument with the fit or fitoptions functions. you can plot excluded data by supplying an exclude or outliers argument with the plot function.

exclude data using a simple rule

for a simple example, load data and fit a gaussian distribution, excluding some data with an expression. then plot the fit, data and the excluded points.

[x, y] = titanium;
f1 = fit(x',y','gauss2','exclude',x<800);
plot(f1,x,y,x<800)

figure contains an axes object. the axes object with xlabel x, ylabel y contains 3 objects of type line. one or more of the lines displays its values using only markers these objects represent data, excluded data, fitted curve.

exclude data by distance from the model

it can be useful to exclude outliers by distance from the model, using standard deviations. the following example shows how to identify outliers using distance greater than 1.5 standard deviations from the model, and compares with a robust fit which gives lower weight to outliers.

create a baseline sinusoidal signal:

xdata = (0:0.1:2*pi)'; 
y0 = sin(xdata);

add noise to the signal with non-constant variance:

% response-dependent gaussian noise
gnoise = y0.*randn(size(y0));
% salt-and-pepper noise
spnoise = zeros(size(y0)); 
p = randperm(length(y0));
sppoints = p(1:round(length(p)/5));
spnoise(sppoints) = 5*sign(y0(sppoints));
ydata = y0   gnoise   spnoise;

fit the noisy data with a baseline sinusoidal model:

f = fittype('a*sin(b*x)'); 
fit1 = fit(xdata,ydata,f,'startpoint',[1 1]);

identify outliers as points at a distance greater than 1.5 standard deviations from the baseline model, and refit the data with the outliers excluded:

fdata = feval(fit1,xdata); 
i = abs(fdata - ydata) > 1.5*std(ydata); 
outliers = excludedata(xdata,ydata,'indices',i);
fit2 = fit(xdata,ydata,f,'startpoint',[1 1],...
           'exclude',outliers);

compare the effect of excluding the outliers with the effect of giving them lower bisquare weight in a robust fit:

fit3 = fit(xdata,ydata,f,'startpoint',[1 1],'robust','on');

plot the data, the outliers, and the results of the fits:

plot(fit1,'r-',xdata,ydata,'k.',outliers,'m*') 
hold on
plot(fit2,'c--')
plot(fit3,'b:')
xlim([0 2*pi])

figure contains an axes object. the axes object with xlabel x, ylabel y contains 5 objects of type line. one or more of the lines displays its values using only markers these objects represent data, excluded data, fitted curve.

see also

|

related topics

网站地图