以下代码中α=0.02
ltx1=[4.5,8.0,5.0,2.0,3.5,5.5,5.0,7.5,5.5,7.5] ltx2=[3.0,5.0,2.0,4.0,5.0,5.0,3.0,3.0] def compute(ltx): le=len(ltx) sum=0 S=0 for i in range(0,le): sum+=ltx[i] avg=sum/le print('avg:',avg) for i in range(0,le): S+=(ltx[i]-avg)*(ltx[i]-avg) s=S/(le-1) print('s²:',s) return s s1=compute(ltx1) s2=compute(ltx2) #查表F0.01(9,7)=6.72 #查表F1-0.01(9,7)=1/(5.61) se1=s1/s2*(1/6.72) se2=s1/s2*5.61 print('σ₁²/σ₂²的置信区间为',(se1,se2))