资源预览内容
第1页 / 共11页
第2页 / 共11页
第3页 / 共11页
第4页 / 共11页
第5页 / 共11页
第6页 / 共11页
第7页 / 共11页
第8页 / 共11页
第9页 / 共11页
第10页 / 共11页
亲,该文档总共11页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
% 标准正态分布的密度计算 y=normpdf(0, 0,1)y =0.3989% 标准正态分布的概率计算 pro=normcdf(3, 0,1)-normcdf(-3, 0,1)pro =0.9973% 标准正态分布的分位数计算quantile=norminv(0.95,0,1)quantile =1.6449 quantile=norminv(0.025,0.975,0,1)quantile = -1.9600 1.9600 quantile=binoinv(0.025,0.975,100,0.1)quantile =5 16% 标准正态分布的密度曲线图x=-3:0.1:3;y=1/sqrt(2*pi)*exp(-x.2/2);plot(x, y)或 ezplot(1/sqrt(2*pi)*exp(-x2/2),-3,3)%标准正态随机数的直方图x=random(norm,0,1,1,1000);hist(x)% 大数定律的验证:独立同分布于 U0,1的随机变量的均值与方差的近似n=100000; x=; err=; err1=;for i=1000:1000:nu=random(Uniform,0,1,1,1000);x=x,u;ave=sum(x)/length(x);err=err,abs(ave-0.5)/0.5; %相对误差dev=sum(x-ave).2)/(length(x)-1);err1=err1,abs(dev-1/12)*12; %相对误差endi=1000:1000:n;plot(i, err, r*, i, err1, b)% 中心极限定理的验证:独立同分布于 U0,1的随机变量的和的分布n=100000;u1=random(Uniform,0,1,1,n); hist(u1)u2=random(Uniform,0,1,1,n); hist(u1+u2)u3=random(Uniform,0,1,1,n); hist(u1+u2+u3)u4=random(Uniform,0,1,1,n); hist(u1+u2+u3+u4)u5=random(Uniform,0,1,1,n); hist(u1+u2+u3+u4+u5)u6=random(Uniform,0,1,1,n); hist(u1+u2+u3+u4+u5+u6)% 中心极限定理的验证:独立同分布于 B(10,0.1)的随机变量的和的分布n=100000;u1=random(Binomial,10,0.1,1,n);hist(u1)u2=random(Binomial,10,0.1,1,n);hist(u1+u2)u3=random(Binomial,10,0.1,1,n);hist(u1+u2+u3)u4=random(Binomial,10,0.1,1,n);hist(u1+u2+u3+u4)u5=random(Binomial,10,0.1,1,n);hist(u1+u2+u3+u4+u5)u6=random(Binomial,10,0.1,1,n);hist(u1+u2+u3+u4+u5+u6)u7=random(Binomial,10,0.1,1,n);hist(u1+u2+u3+u4+u5+u6+u7)u8=random(Binomial,10,0.1,1,n);hist(u1+u2+u3+u4+u5+u6+u7+u8)u9=random(Binomial,10,0.1,1,n);hist(u1+u2+u3+u4+u5+u6+u7+u8+u9)% 中心极限定理的验证:独立同分布于 U0,1的随机变量的均值的分布ave1=; ave2=;for i=1:600 %取 600 个样本ave1=ave1,sum(random(Uniform,0,1,1,10)/10; %样本容量为 10ave2=ave2,sum(random(Uniform,0,1,1,50)/50; %样本容量为 50end hist(ave1)clf;hist(ave2)%关于常用随机数的使用介绍 help randomRANDOM Generates random numbers from a named distribution.The appropriate syntax depends on the number of parameters inthe distribution you are using:R = RANDOM(NAME,A,M,N) returns an M-by-N array of randomnumbers from the named distribution with parameter A.R = RANDOM(NAME,A,B,M,N) returns an M-by-N array of randomnumbers from the named distribution with parameters A, and B.R = RANDOM(NAME,A,B,C,M,N) returns an M-by-N array of randomnumbers from the named distribution with parameters A, B, and C.The name can be: beta or Beta, bino or Binomial,chi2 or Chisquare, exp or Exponential, f or F, gam or Gamma, geo or Geometric, hyge or Hypergeometric, logn or Lognormal, nbin or Negative Binomial, ncf or Noncentral F, nct or Noncentral t, ncx2 or Noncentral Chi-square,norm or Normal, poiss or Poisson, rayl or Rayleigh,t or T, unif or Uniform, unid or Discrete Uniform,weib or Weibull.Both M and N are integers. Alternatively you can omit N andspecify M as a vector of two integers. If you omit both M andN, then R is a 1-by-1 array.
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号