资源预览内容
第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
亲,该文档总共4页全部预览完了,如果喜欢就下载吧!
资源描述
多维高斯分布讲解高斯分布高斯分布:1维高斯分布公式:多维高斯分布公式:对于1维的来说是期望,是方差;对于多维来说D表示X的维数,表示D*D的协方差矩阵,定义为,为该协方差的行列式的值。代码如下:m=01;S=eye(2);x1=0.21.3;x2=2.2-1.3;pg1=comp_gauss_dens_val(m,S,x1)pg2=comp_gauss_dens_val(m,S,x2)其中comp_gauss_dens_val函数文件的代码如下:functionz=comp_gauss_dens_val(m,S,x)l,c=size(m);z=(1/(2*pi)(l/2)*det(S)0.5)*exp(-0.5*(x-m)*inv(S)*(x-m);题目大致意思就是判断x是属于w1还是w2?代码如下:P1=0.5;P2=0.5;m1=11;m2=33;S=eye(2);x=1.81.8;p1=P1*comp_gauss_dens_val(m1,S,x)p2=P2*comp_gauss_dens_val(m2,S,x)题目大致意思就是给出正态分布的期望和方差构造出一些服从这个分布的数据点代码如下:%Generatethefirstdataset(case#1)randn(seed,0);m=00;S=10;01;N=500;X=mvnrnd(m,S,N);%Plotthefirstdatasetfigure(1),plot(X(1,:),X(2,:),.);figure(1),axisequalfigure(1),axis(-77-77)%Generateandplottheseconddataset(case#2)m=00;S=0.20;00.2;N=500;X=mvnrnd(m,S,N);figure(2),plot(X(1,:),X(2,:),.);figure(2),axisequalfigure(2),axis(-77-77)%Generateandplotthethirddataset(case#3)m=00;S=20;02;N=500;X=mvnrnd(m,S,N);figure(3),plot(X(1,:),X(2,:),.);figure(3),axisequalfigure(3),axis(-77-77)%Generateandplotthefourthdataset(case#4)m=00;S=0.20;02;N=500;X=mvnrnd(m,S,N);figure(4),plot(X(1,:),X(2,:),.);figure(4),axisequalfigure(4),axis(-77-77)%Generateandplotthefifthdataset(case#5)m=00;S=20;00.2;N=500;X=mvnrnd(m,S,N);figure(5),plot(X(1,:),X(2,:),.);figure(5),axisequalfigure(5),axis(-77-77)%Generateandplotthesixthdataset(case#6)m=00;S=10.5;0.51;N=500;X=mvnrnd(m,S,N);figure(6),plot(X(1,:),X(2,:),.);figure(6),axisequalfigure(6),axis(-77-77)%Generateandplottheseventhdataset(case#7)m=00;S=.30.5;0.52;N=500;X=mvnrnd(m,S,N);figure(7),plot(X(1,:),X(2,:),.);figure(7),axisequalfigure(7),axis(-77-77)%Generateandplottheeighthdataset(case#8)m=00;S=.3-0.5;-0.52;N=500;X=mvnrnd(m,S,N);figure(8),plot(X(1,:),X(2,:),.);figure(8),axisequalfigure(8),axis(-77-77)即生成了8副图像
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号