程序:proc iml;
n=10;p=2;
xx={x1 x2};
use awt5_2;
read all var xx into x;
e={[10] 1};
x0=(e*x)/n;
mm=i(10)-j(10,10,1)/n;
a=x`*mm*x;
s=a/(n-1);
si=inv(s);print x0 s si; /*si为s的逆矩阵*/
use awt5_2(obs=1);
read all var xx into xx1;
d1=(xx1-x0)*si*(xx1-x0)`; /*d 为马氏距离*/
use awt5_2(firstobs=2 obs=2);
read all var xx into xx2;
d2=(xx2-x0)*si*(xx2-x0)`;
use awt5_2(firstobs=3 obs=3);
read all var xx into xx3;
d3=(xx3-x0)*si*(xx3-x0)`;
use awt5_2(firstobs=4 obs=4);
read all var xx into xx4;
d4=(xx4-x0)*si*(xx4-x0)`;
use awt5_2(firstobs=5 obs=5);
read all var xx into xx5;
d5=(xx5-x0)*si*(xx5-x0)`;
use awt5_2(firstobs=6 obs=6);
read all var xx into xx6;
d6=(xx6-x0)*si*(xx6-x0)`;
use awt5_2(firstobs=7 obs=7);
read all var xx into xx7;
d7=(xx7-x0)*si*(xx7-x0)`;
use awt5_2(firstobs=8 obs=8);
read all var xx into xx8;
d8=(xx8-x0)*si*(xx8-x0)`;
use awt5_2(firstobs=9 obs=9);
read all var xx into xx9;
d9=(xx9-x0)*si*(xx9-x0)`;
use awt5_2(firstobs=10 obs=10);
read all var xx into xx10;
d10=(xx10-x0)*si*(xx10-x0)`;
print d1 d2 d3 d4 d5 d6 d7 d8 d9 d10;
run;
通过d1=(xx1-x0)*si*(xx1-x0)`可计算各样本到达样本均值的马氏距离。
(5)计算样本点落在二元正态50%置信区域内的比率。(χ22(0.5)=1.39)