- 积分
- 568
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-6-24
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2014-6-25 08:31:32
|
显示全部楼层
A=xlsread('shiyan.xls')
x=A(:,1);
y=A(:,2);
N=length(y);
n=length(y);
Sk=zeros(size(y));
UFk=zeros(size(y));
s = 0;
for i=2:n
for j=1:i
if y(i)>y(j)
s=s+1;
else
s=s+0;
end;
end;
Sk(i)=s;
E=i*(i-1)/4;
Var=i*(i-1)*(2*i+5)/72;
UFk(i)=(Sk(i)-E)/sqrt(Var);
end;
y2=zeros(size(y));
Sk2=zeros(size(y));
UBk=zeros(size(y));
s=0;
for i=1:n
y2(i)=y(n-i+1);
end;
for i=2:n
for j=1:i
if y2(i)>y2(j)
s=s+1;
else
s=s+0;
end;
end;
Sk2(i)=s;
E=i*(i-1)/4;
Var=i*(i-1)*(2*i+5)/72;
UBk(i)=0-(Sk2(i)-E)/sqrt(Var);
end;
UBk2=zeros(size(y));
for i=1:n
UBk2(i)=UBk(n-i+1);
end;
xlswrite('f:\test2.xls',UFk,'Sheet1','A1');
xlswrite('f:\test2.xls',UBk2,'Sheet1','B1');
figure(3)
plot(x,UFk,'r-','linewidth',1.5);
hold on
plot(x,UBk2,'b-.','linewidth',1.5);
plot(x,1.96*ones(N,1),':','linewidth',1);
axis([min(x),max(x),-4,8]);
legend('UF统计量','UB统计量','0.05显著水平');
xlabel('t (year)','FontName','TimesNewRoman','FontSize',12);
ylabel('统计量','FontName','TimesNewRoman','Fontsize',12);
hold on
plot(x,0*ones(N,1),'-.','linewidth',1);
plot(x,1.96*ones(N,1),':','linewidth',1);
plot(x,-1.96*ones(N,1),':','linewidth',1); |
|