MATLAB 生成多维高斯分布概率密度函数
作者:互联网
1 clear all; 2 close all; 3 clc; 4 5 randn('seed',0); 6 %%一维高斯函数 7 mu=0; 8 sigma=1; 9 x=-6:0.1:6; 10 y=normpdf(x,mu,sigma); 11 plot(x,y); 12 figure; 13 14 %%二维或多维高斯函数 15 mu=[0 0]; 16 sigma=[0.3 0;0 0.35]; 17 [x y]=meshgrid(linspace(-8,8,80)',linspace(-8,8,80)'); 18 X=[x(:) y(:)]; 19 z=mvnpdf(X,mu,sigma); 20 surf(x,y,reshape(z,80,80)); 21 hold on; 22 %再生成一个 23 mu=[4 0]; 24 sigma=[1.2 0;0 1.85]; 25 [x y]=meshgrid(linspace(-8,8,80)',linspace(-8,8,80)'); 26 X=[x(:) y(:)]; 27 z=mvnpdf(X,mu,sigma); 28 surf(x,y,reshape(z,80,80));
标签:概率密度函数,%%,reshape,mu,MATLAB,80,sigma,高斯分布,linspace 来源: https://www.cnblogs.com/ybqjymy/p/13645960.html