主要内容

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. 单击要排除在适合图或残差绘图中的点。或者,单击并拖动以定义矩形并删除所有封闭点。

    A removed plot point becomes a red cross in the plots. If you have汽车fitting selected in the合身section of theCurve Fittertab, the Curve Fitter app refits the surface without the point. Otherwise, if you haveManualfitting selected, you can click合身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 selectGo to X-Y view,Go to X-Z view, orGo to Y-Z view.

取代个人排除分健康,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 selectClear 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 theCurve Fitter标签,在数据section, click排除规则.

  2. 在“排除规则”对话框中,指定要排除的数据。在任何框中输入数字以定义开头或结束间隔以排除在x,y或z数据中。

    The Curve Fitter app displays shaded pink areas on the plots to show excluded ranges. Excluded points become red.

Remove Outliers Programmatically

此示例显示如何在以编程方式拟合曲线时,如何删除异常值,使用“排除”名称/值对参数使用拟合或fitOptions函数。您可以通过提供具有绘图功能的排除或异常值参数来绘制数据。

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','排除',x<800); plot(f1,x,y,x<800)

Figure contains an axes object. The axes object contains 3 objects of type line. These objects represent data, excluded data, fitted curve.

Exclude Data by Distance from the Model

使用标准偏差,通过从模型的距离排除异常值,这很有用。以下示例显示了如何识别使用从模型的距离大于1.5标准偏差的距离的异常值,并与强大的拟合进行比较,从而为异常值提供更低的重量。

Create a baseline sinusoidal signal:

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

Add noise to the signal with non-constant variance:

%响应依赖性高斯噪声gnoise = y0.*randn(size(y0));%盐和辣椒噪音spnoise = zeros(尺寸(y0));p = randperm(长度(y0));Sppoints = P(1:圆(长度(p)/ 5));spnoise(sppoints)= 5 * sign(y0(sppoints));Ydata = Y0 + Gnoise + Spnoise;

使用基线正弦型模型适合嘈杂的数据:

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,'索引',一世);fit2 = fit(xdata,ydata,f,'StartPoint',[1 1],...'排除',outliers);

比较不包括异常值的效果,使其在强大的配合中给予它们较低的Bisquare重量:

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*') 抓住plot(fit2,'C - ') plot(fit3,'B:') xlim([0 2*pi])

Figure contains an axes object. The axes object contains 5 objects of type line. These objects represent data, excluded data, fitted curve.

See Also

|

相关话题