matlab程序解释n=5;a=0.9;x_a=chi2inv(a,n);x=0:0.1:15;yd_c=chi2pdf(x,n);plot(x,yd_c,'b'),hold onxxf=0:0.1:x_a;yyf=chi2pdf(xxf,n);fill([xxf,x_a],[yyf,0],'g')text(x_a*1.01,0.01,num2str(x_a))text(10,0.10,['\fontsize{16}X~{\chi}^2(4)'])text(1.5,0.05,'\

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 03:29:23

matlab程序解释n=5;a=0.9;x_a=chi2inv(a,n);x=0:0.1:15;yd_c=chi2pdf(x,n);plot(x,yd_c,'b'),hold onxxf=0:0.1:x_a;yyf=chi2pdf(xxf,n);fill([xxf,x_a],[yyf,0],'g')text(x_a*1.01,0.01,num2str(x_a))text(10,0.10,['\fontsize{16}X~{\chi}^2(4)'])text(1.5,0.05,'\
matlab程序解释
n=5;a=0.9;
x_a=chi2inv(a,n);
x=0:0.1:15;yd_c=chi2pdf(x,n);
plot(x,yd_c,'b'),hold on
xxf=0:0.1:x_a;yyf=chi2pdf(xxf,n);
fill([xxf,x_a],[yyf,0],'g')
text(x_a*1.01,0.01,num2str(x_a))
text(10,0.10,['\fontsize{16}X~{\chi}^2(4)'])
text(1.5,0.05,'\fontsize{22}alpha=0.9')

matlab程序解释n=5;a=0.9;x_a=chi2inv(a,n);x=0:0.1:15;yd_c=chi2pdf(x,n);plot(x,yd_c,'b'),hold onxxf=0:0.1:x_a;yyf=chi2pdf(xxf,n);fill([xxf,x_a],[yyf,0],'g')text(x_a*1.01,0.01,num2str(x_a))text(10,0.10,['\fontsize{16}X~{\chi}^2(4)'])text(1.5,0.05,'\
n=5;    %卡方分布参数: 自由度
a=0.9;  %P值
x_a=chi2inv(a,n);   % 根据P值反查临界值
%绘制卡方分布图
x=0:0.1:15;
yd_c=chi2pdf(x,n);  %获得相应分布密度值
plot(x,yd_c,'b'),hold on  %画图

%绘制分布函数着色部分
xxf=0:0.1:x_a;  % 0~临界值
yyf=chi2pdf(xxf,n);
fill([xxf,x_a],[yyf,0],'g')  %以绿色填充

%标注
text(x_a*1.01,0.01,num2str(x_a));  %标注临界值
text(10,0.10,['\fontsize{16}X~{\chi}^2(4)']);  %标注分布名
text(1.5,0.05,'\fontsize{22}\alpha=0.9'); % 标注P值(原为alpha已改为α)