云南财经大学2013至2014学年第一学期《ComputatinoalStatistics(统计计算)》课程期中考试
试卷
云南省高中会考试卷哪里下载南京英语小升初试卷下载电路下试卷下载上海试卷下载口算试卷下载
(试)Answerallquestions.Marksareshowninparentheses.Submita.rarfilenamedby“yourClassname_Chinesename_U.no.”Therarfileshouldatleastincludefive.mfiles(1.mfor1q),andawordfilethatconciselysummarizesyourfinalanswers.1.(20marks)Whenarandomvariableisequallylikelytobeeitherpositiveornegative,thentheLaplacianorthedoubleexponentialdistributioncanbeusedtomodelit.TheLaplacianprobabilitydensityfunctionforisgivenbyWriteaMATLABfunctionthatwillevaluatetheLaplacianprobabilitydensityfunctionforgivenvaluesinthedomain.WriteaMATLABfunctionthatwillevaluatetheLaplaciancumulativedistributionfunction.Plottheprobabilitydensityfunctionwhen.Answer:lambda=randx=randpdf=exppdf(x,1/lambda)cdf=exppdf(x,1/lambda)lambda=1x=(0:10);pdf=exppdf(x,1/lambda);subplot(1,2,1),plot(x,pdf)title('ProbabilityDensityFunction')xlabel('X'),ylabel('f(X)')axis((0:10))axissquare2.(20marks)Generatearandomsampleofsize500thatisuniformlydistributedovertheinterval.Plottheempiricaldistributionfunctionovertheinterval.Answer:n=500x=randn(1,500)(f,y)=ecdf(x)subplot(-0.1,1.1)plot(y,f)3.(20marks)Generatearandomsampleofsize100fromauniformdistribution(setthegeneratortotheinitialstate).Whatarethesamplequantilesfor?Answer:>>x=sort(rand(1,100));q1=median(x(1:46));q2=median(x(1:78));q3=median(x(1:96));q4=median(x(85:100))q4=0.87804.(20marks)Writeafunctionthatwillgeneratechi-squarerandomvariableswithdegreesoffreedombygeneratingstandardnormals,squaringthemandthenaddingthemup.Thisusesthefactthatischi-squarewithdegreesoffreedom.Generatesomerandomvariablesandplotinahistogram.Thedegreesoffreedomshouldbeaninputargumentsetbytheuser.Answer:%whenγ=4,wecanget:Z1=randnX1=sum(Z1.^2)Z2=randnX2=sum(Z2.^2)Z3=randnX3=sum(Z3.^2)Z4=randnX4=sum(Z4.^2)Y=X1+X2+X3+X4Z1=-0.4326X1=0.1871Z2=-1.6656X2=2.7742Z3=0.1253X3=0.0157Z4=0.2877X4=0.0828Y=3.05975.(20marks)Generatediscreteuniformrandomnumbersthathasprobabilitymassfunctiongivenbyandshowtheportionofeachnumberyougenerated.Answer:%Setupstoragespaceforthevariables.X=zeros(1,100);%Thesearethex'sinthedomain.x=0:5;%Thesearetheprobabilitymasses.pr=[0.20.250.150.4];%Generate100rv’sfromthedesireddistribution.fori=1:100u=rand;%GeneratetheU.ifu<=pr(1)X(i)=x(1);elseifu<=sum(pr(1:2))%Ithastobebetween0.2and0.45.X(i)=x(2);elseifu<=sum(pr(2:3))X(i)=x(3)elseX(i)=x(4);%Ithastobebetween0.6and1.endend%Findtheproportionofeachnumber.x1=length(find(X==1))/100x2=length(find(X==2))/100x3=length(find(X==3))/100x4=length(find(X==4))/100x1=0.2700x2=0x3=0.5900x4=0NOTE:Youshoulduseefficientvector/matrixoperationsandavoidusingfor/whileloopsasfaraspossible.