随机过程matlab程序

上传人:M****1 文档编号:556546903 上传时间:2023-01-12 格式:DOCX 页数:18 大小:57KB
返回 下载 相关 举报
随机过程matlab程序_第1页
第1页 / 共18页
随机过程matlab程序_第2页
第2页 / 共18页
随机过程matlab程序_第3页
第3页 / 共18页
随机过程matlab程序_第4页
第4页 / 共18页
随机过程matlab程序_第5页
第5页 / 共18页
点击查看更多>>
资源描述

《随机过程matlab程序》由会员分享,可在线阅读,更多相关《随机过程matlab程序(18页珍藏版)》请在金锄头文库上搜索。

1、基本操作-5/+A2area=pi*A2x1=1+1/2+1/3+1/4+1/5+1/6exp(acos)a=1 2 3;4 5 6;7 8 9a=1:3,4:6,7:9a1=6: -1:1a=eye(4) a1=eye(2,3)b=zeros(2,10) c=ones(2,10) c1=8*ones(3,5)d=zeros(3,2,2) ;r1=rand(2, 3)r2=5-10*rand(2, 3)r4=2*randn(2,3)+3arr1= arr1(3) arr1(1 4) arr1(1:2:5)arr2=1 2 3; -2 -3 -4;3 4 5arr2(1,:)arr2(:,1:2

2、:3)arr3=1 2 3 4 5 6 7 8arr3(5:end) arr3(end)绘图x=0:1:10;y=xA2-10*x+15;plot(x,y)x=0:pi/20:2*piy1=sin(x);y2=cos(x);plot(x,y1,b-);hold on;plot(x,y2, k - );legend ( sin x , cos x );x=0:pi/20:2*pi;y=sin(x);figure(1)plot(x,y, r-)grid on以二元函数图z = xexp(-xA2-yA2) 为例讲解基本操作,首先需要利用meshgrid函数生成X-Y平面的网格数据,如下所示:xa

3、= -2:2;ya = xa;x,y = meshgrid(xa,ya);z = x.*exp(-x.A2 - y.A2);mesh(x,y,z);建立M文件function fenshu( grade )if grade disp( The grade is A.);elseif grade disp( The grade is B.);elseif grade disp( The grade is C.);elseif grade disp(The grade is D.);elsedisp(The grade is F.);endendendendend function y=func(

4、x)if abs(x)1y=sqrt(1-xA2);else y=xA2-1;end function summ( n)i = 1;sum = 0;while ( i = n )sum = sum+i;i = i+1;endstr = ? &1 ?ao,num2str(sum);disp(str) end求极限syms xlimit(1+x)A(1/x),x,0,right) 求导数syms x;f=(sin(x)/x); diff(f)diff(log(sin(x)求积分syms x;int(xA2*log(x)syms x;int(abs(x-1),0,2)常微分方程求解dsolve(Dy

5、+2*x*y=x*exp(-xA2),x)计算偏导数x/(xA2 + yA2 + zA2)A(1/2) diff(xA2+yA2+zA2)A(1/2),x,2)重积分int(int(x*y,y,2*x,xA2+1),x,0,1)级数syms n;symsum(1/2An,1,inf)Taylor 展开式求 y=exp(x) 在 x=0 处的 5 阶 Taylor 展开式 taylor(exp(x),0,6)矩阵求逆A=0 -6 -1; 6 2 -16; -5 20 -10det(A)inv(A)特征值、特征向量和特征多项式A=0 -6 -1; 6 2 -16; -5 20 -10; lambd

6、a=eig(A)v,d=eig(A)poly(A)多项式的根与计算p=1 0 -2 -5;r=roots(p)p2=poly(r)y1=polyval(p,4)例子:x=-3:3y=,;A=2*x, 2*y, ones(size(x);B=x.A2+y.A2;c=inv(A*A)*A*B;r=sqrt(c(3)+c(1)A2+c(2)A2)例子ezplot(-2/3*exp(-t)+5/3*exp(2*t),-2/3*exp(-t)+2/3*exp(2*t),0,1) grid on; axis(0, 12, 0, 5)密度函数和概率分布设 x b(20,binopdf(2,20,分布函数设

7、x N(1100,50 2) , y N(1150,80 2) ,则有 normcdf(1000,1100,50)=, =normcdf(1000,1150,80)=, =统计量数字特征x= mean(x)max(x)min(x)std(x)syms p k;Ex=symsum(k*p*(1-p)A(k-1),k,1,inf)syms x y;f=x+y;Ex=int(int(x*y*f,y,0,1),0,1)参数估计例:对某型号的20 辆汽车记录其5L 汽油的行驶里程(公里),观测数据如下:设行驶里程服从正态分布,试用最大似然估计法求总体的均值和方差。x1=;x2=;x=x1 x2;p=ml

8、e(norm,x);muhatmle=p(1),sigma2hatmle=p(242m,s,mci,sci=normfit(x,假设检验例:下面列出的是某工厂随机选取的20 只零部件的装配时间(分):设装配时间总体服从正态分布,标准差为,是否认定装配时间的均值在的水平下不小于10。解: :在正态总体的方差已知时MATLAB匀值检验程序:x1=;x2=;x=x1 x2;m=10;sigma=;a=;h,sig,muci=ztest(x,m,sigma,a,1)得到: h =1 , sig = , muci = Inf% PPT 例 2 一维正态密度与二维正态密度syms x y;s=1; t=2

9、;mu1=0; mu2=0; sigma1=sqrt(sA2); sigma2=sqrt(tA2);x=-6:6;f1=1/sqrt(2*pi*sigma1)*exp(-(x-mu1).A2/(2*sigma1A2);f2=1/sqrt(2*pi*sigma2)*exp(-(x-mu2).A2/(2*sigma2A2);plot(x,f1,r-,x,f2,k-.)rho=(1+s*t)/(sigma1*sigma2);f=1/(2*pi*sigma1*sigma2*sqrt(1-rhoA2)*exp(-1/(2*(1-rhoA2)*(x-mu1)A2/sigma1 2-2*rho*(x-mu1

10、)*(y-mu2)/(sigma1*sigma2)+(y-mu2)A2/sigma2A2);ezsurf(f)% P34 例 输出p1 =p2 = ans =% P40 例输出p3 =% P40 例输出p4 =% P35-37(Th3.1.1) 解微分方程% 输入:syms p0 p1 p2 ;S=dsolve(Dp0=-lamda*p0,Dp1=-lamda*p1+lamda*p0,Dp2=-lamda*p2+lamda*p1, p0(0) = 1,p1(0) = 0,p2(0) = 0);,% 输出:ans =exp(-lamda*t), exp(-lamda*t)*t*lamda, 1/

11、2*exp(-lamda*t)*tA2*lamdaA2% P40 泊松过程仿真% simulate 10 timesclear;m=10; lamda=1; x=;for i=1:ms=exprnd(lamda, seed,1 );使得生成随机数的个数是一样的% seed 是用来控制生成随机数的种子x=x,exprnd(lamda);t1=cumsum(x);endx,t1%输出:ans =%输入:N=;for t=0:(t1(m)+1)if tt1(1)N=N,0;elseif tt1(2)N=N,1;elseif tt1(3)N=N,2;elseif tt1(4)N=N,3;elseif

12、tt1(5)N=N,4;elseif tt1(6)N=N,5;elseif tt1(7)N=N,6;elseif tt1(8)N=N,7;elseif tt1(9)N=N,8;elseif tt1(10)N=N,9;else N=N,10;endendplot(0:(t1(m)+1),N,r-)%输出:% simulate 100 times clear;m=100; lamda=1; x=; for i=1:ms= rand( seed );x=x,exprnd(lamda);t1=cumsum(x);endx,t1N=;for t=0:(t1(m)+1)if t=t1(i) & tt1(m

13、) N=N,m;endendplot(0:(t1(m)+1),N,r-)% 输出:% P48 非齐次泊松过程仿真% simulate 10 times clear;m=10; lamda=1; x=;% exprnd(lamda,seed,1 ); set seedsfor i=1:ms=rand( seed );x=x,exprnd(lamda);t1=cumsum(x); endx,t1N=; T=;for t=0:(t1(m)+1)T=T,t.A3;% time is adjusted, cumulative intensity function is tA3.if t=t1(i) & tt1(m) N=N,m;endend plot(T,N, r- )% output ans =10 times simulation100 times simulation% P50 复合泊松过程仿真% simulate 100 timesclear;%

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 营销创新

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号