Main Content

이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.

excludedata

피팅에서 데이터 제외

설명

예제

tf = excludedata(x,y,'box',box)box로 지정된 xy 평면의 상자 밖에 어떤 요소가 있는지 나타내는 논리형 배열을 반환합니다. 상자 밖에 있는 데이터 점에 대해서는 tf의 요소는 1이고 상자 안에 있는 데이터 점에 대해서는 0입니다. fit를 사용해 곡선을 피팅할 때 데이터를 제외하려면 tf'Exclude' 값으로 지정하십시오.

예제

tf = excludedata(x,y,'domain',domain)x 값이 구간 domain 밖에 있는 데이터 점을 식별합니다.

예제

tf = excludedata(x,y,'range',range)y 값이 구간 range 밖에 있는 데이터 점을 식별합니다.

tf = excludedata(x,y,'indices',indices)indices와 같은 인덱스를 가진 데이터 점을 식별합니다.

예제

모두 축소

임의의 데이터를 사용해 제외 규칙을 시각화합니다.

임의의 xy 데이터를 생성합니다.

xdata = -3 + 6*rand(1,1e4);
ydata = -3 + 6*rand(1,1e4);

일례로, 상자 [-1 1 -1 1] 안에 있거나 정의역 [-2 2] 밖에 있는 데이터는 제외합니다.

outliers1 = ~excludedata(xdata,ydata,'box',[-1 1 -1 1]);
outliers2 = excludedata(xdata,ydata,'domain',[-2 2]);
outliers = outliers1|outliers2;

제외되지 않은 데이터를 플로팅합니다. 흰색 영역은 제외된 영역에 해당합니다.

plot(xdata(~outliers),ydata(~outliers),'.')
axis([-3 3 -3 3])
axis square

Figure contains an axes object. The axes contains a line object which displays its values using only markers.

2000년도 미국 대통령 선거에서 플로리다주의 투표수와 카운티 이름을 불러옵니다.

load flvote2k

두 주요 정당 후보인 부시와 고어의 투표수를 사용하고 제3의 후보인 뷰캐넌의 투표수는 예측 변수로 사용하여 산점도를 플로팅합니다.

plot(bush,buchanan,'rs')
hold on
plot(gore,buchanan,'bo')
legend('Bush data','Gore data')

Figure contains an axes object. The axes object contains 2 objects of type line. One or more of the lines displays its values using only markers These objects represent Bush data, Gore data.

부시나 고어에게 가야 할 표 중 고정된 일정 비율이 뷰캐넌에게 가는 모델을 가정합니다.

f = fittype({'x'})
f = 
     Linear model:
     f(a,x) = a*x

논란이 많은 “나비 모양” 투표용지를 사용하지 않았던 부재 투표자의 데이터는 제외합니다.

nobutterfly = strcmp(counties,'Absentee Ballots');

부재자 투표를 제외한 두 데이터 세트에 대해 이 모델의 겹제곱 가중치 로버스트 피팅을 수행합니다.

bushfit = fit(bush,buchanan,f,'Exclude',nobutterfly,'Robust','on');
gorefit = fit(gore,buchanan,f,'Exclude',nobutterfly,'Robust','on');

로버스트 피팅에서는 이상값에 낮은 가중치가 주어지므로, 로버스트 피팅의 큰 잔차를 사용해 이상값을 식별할 수 있습니다.

figure
plot(bushfit,bush,buchanan,'rs','residuals')
hold on
plot(gorefit,gore,buchanan,'bo','residuals')

Figure contains an axes object. The axes object with xlabel x contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent data, zero line.

잔차를 계산합니다.

bushres = buchanan - feval(bushfit,bush);
goreres = buchanan - feval(gorefit,gore);

큰 잔차를 치역 [-500 500] 밖에 있는 것으로 식별합니다.

bushoutliers = excludedata(bush,bushres,'range',[-500 500]);
goreoutliers = excludedata(gore,goreres,'range',[-500 500]);

이상값에 해당하는 카운티를 표시합니다. 마이애미데이드 카운티와 브라우어드 카운티가 가장 큰 예측 변수 값에 대응됩니다. 플로리다주에서 “나비 모양” 투표용지를 사용한 유일한 카운티인 팜비치 카운티가 가장 큰 잔차 값에 대응됩니다.

counties(bushoutliers)
ans = 2x1 cell
    {'Miami-Dade'}
    {'Palm Beach'}

counties(goreoutliers)
ans = 3x1 cell
    {'Broward'   }
    {'Miami-Dade'}
    {'Palm Beach'}

입력 인수

모두 축소

데이터 값의 데이터 지점으로, 숫자형 벡터로 지정됩니다.

데이터 값으로, 숫자형 벡터로 지정됩니다.

밖에 있는 데이터를 찾기 위한 상자로, 4개의 요소를 가진 숫자형 벡터 [xmin xmax ymin ymax]로 지정됩니다.

예: [-1 1 0 2]

밖에 있는 데이터를 찾기 위한 정의역으로, 2개의 요소를 가진 숫자형 벡터 [xmin xmax]로 지정됩니다.

예: [-1 1]

밖에 있는 데이터를 찾기 위한 치역으로, 2개의 요소를 가진 숫자형 벡터 [ymin ymax]로 지정됩니다.

예: [3 4]

찾을 데이터 점의 인덱스로, 숫자형 벡터로 지정됩니다.

예: [3 7 9]

버전 내역

R2006a 이전에 개발됨

참고 항목

|