《非参数统计》与MATLAB编程第二章描述性统计

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

第二章描述性统计2.1表格法和图形法表2.1灯丝寿命数据107736897767994599857738154657180848862617998636566627986687461826598637162116658864797879778689767485738068788972586982729278887710388636888816473759062897171747074708561658175629471858483639268816279839361656292656466837070817772846759587383786666947763667568767376907871101784359676171779196756476727774658286797466869689817185995992946268727760878475775145631028567878084936976897559778368726792898296a=Columns1through171077368977679945998577381546571808479986365666279866874618265986371626479787977868976748573806878897258927888771038863688881647375906289717470856165817562947185848363926881936165629265646683707081777284675978666694776366756876737690787110178617177919675647672777465828679746681718599599294626872776087847577518567878084936976897559778368726792Columns18through2088626111665886982727174706279835873834359678696894563102898296注:a不能复制到MATLAB中。b=reshape(a,200,1);[min(b)max(b)]ans=43116n=histc(b,[40,50,60,70,80,90,100,110,120])n=21052644522410n/200ans=0.01000.05000.26000.32000.22500.11000.02000.00500bar([40,50,60,70,80,90,100,110,120],n,'histc')405060708090100110120020406080405060708090100110120020406080表2.2灯丝寿命数据频率分布灯丝寿命(小时)个数频率(%)40—502150—6010560—70522670—80643280—904522.590—1002211100—11042110-12010.5合计200100c=[23224191063211]bar(c)0-400400-800800-12001200-16001600-20002000-24002400-28002800-32003200-36003600-400005101520253035表2.7赔款样本数据直方图x=[12222335789];y=[11234121111];plot(x,y,'*','markersize',30,'linewidth',4)axis([0,10,0,5])1234567890123345图2.8[mean([1,2,2,2,2,3,3,5,7,8,9])median([1,2,2,2,2,3,3,5,7,8,9])]ans=43切尾均值:trimmeantrimmean(x,percent),其中percent为0到100。当x为向量时,切尾均值为:先去掉x的percent/2的最大值和最小值,再求算术平均值。注意:若length(x)×percent/2恰好为整数时,则就x按大小排序后,两端去掉length(x)×percent/2个数,如果不是整数,则去掉length(x)×percent/2四舍五入数(若小数点后正好等于5,则取小的整数,如1.5还是取1)。如:a=[4912.42333.54556677699]回车trimmean(a,50)回车ans=39.4833(25/2)%×length(x)=2.5,两端切掉2个数。即等于:mean([12.42333.5455667])回车ans=39.4833然后当:trimmean(a,51)回车ans=39.3750(51/2)%×length(x)=2.55,即两端切掉3个数。mean([2333.54556])回车ans=39.3750Trimmean也可处理矩阵,不过只是计算矩阵每列的切尾均值。继续上面,如:b=a';c=[1:10]';d=[b,c];trimmean(d,51)回车ans=39.37505.50002.2.2表示离散程度的数值[var(b)std(b)range(b)]ans=145.454812.060573.0000百分位数:prctile(x,percent),其中percent为0到100,x可为向量或矩阵。[prctile(b,25)prctile(b,75)]ans=66.500084.0000四分位间距:iqr(x)其中x可为向量或矩阵,当x为向量时,iqr(x)为x的75%的百分位数减去25%的百分位数。iqr(b)ans=17.50001406080100ValuesColumnNumberX-上四分位数1.5IQR或下四分位数-X1.5IQR时,X为野值。称“下四分位数-1.5IQR”和“上四分位数+1.5IQR”两个数为内篱笆,“下四分位数-3IQR”和“上四分位数+3IQR”两个数为外篱笆,位于内、外篱笆之间的数称为弱异常值,而在外篱笆的数称为强异常值。区间估计:双侧均值的区间估计:[h,sig,ci,stats]=ttest(b,75,0.05)%95%的置信区间h=0sig=0.2197ci=74.368377.7317stats=tstat:1.2312df:199sd:12.0605[mean(b)-tinv(0.975,199)*std(b)/(200^0.5)mean(b)+tinv(0.975,199)*std(b)/(200^0.5)]ans=74.368377.7317单侧区间估计:[h,sig,ci,stats]=ttest(b,75,0.05,1)h=0sig=0.1098ci=74.6407Infstats=tstat:1.2312df:199sd:12.0605[h,sig,ci,stats]=ttest(b,75,0.05,-1)h=0sig=0.8902ci=-Inf77.4593stats=tstat:1.2312df:199sd:12.0605[mean(b)-tinv(0.95,199)*std(b)/(200^0.5)mean(b)+tinv(0.95,199)*std(b)/(200^0.5)]ans=74.640777.4593§2.2.2偏度formatlongskewness(b)%不修正的偏度系数ans=0.27494548340412moment(b,3)/std(b,1)^3ans=0.27494548340412moment(b,3)/moment(b,2)^1.5ans=0.27494548340412(sum((b-mean(b)).^3)/200)/std(b,1)^3ans=0.27494548340412不修正的偏度系数:2/32333//nxxnxxuskewnessskewness(b,0)%修正的偏度系数ans=0.27702753367296200*(200/(199*198))*moment(b,3)/std(b)^3ans=0.27702753367296修正的偏度系数:3)2(1sxxnnnskewnessi2*(1-normcdf(bs*sqrt(200/6)))ans=0.10972748638965在0.05显著性水平下,接受原假设。为正态分布。§2.2.5峰度x=-6:0.1:6;y=tpdf(x,8);z=normpdf(x,0,8/6);plot(x,y,'-.',x,z,'-','linewidth',5)legend('T分布','正态分布')-6-4-2024600.10.20.30.4T分布正态分布图2.12正态分布和t分布x1=3.5:0.01:6;y1=tpdf(x1,8);z1=normpdf(x1,0,8/6);plot(x1,y1,'-.',x1,z1,'-','linewidth',5)legend('T分布','正态分布')3.544.555.5600.0020.0040.0060.0080.01T分布正态分布图2.13正态分布和t分布的尾部kurtosis(b)ans=3.00483762647840moment(b,4)/std(b,1)^4ans=3.00483762647840kurtosis(b,0)ans=3.03557145622493ku=kurtosis(b,0)ku=3.035571456224932*(1-normcdf((ku-3)*sqrt(200/24)))ans=0.91821222565534

1 / 12
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功