高斯曲线 方差sigma=1,改变均值a(-6, 0,+6)
高斯曲线 均值a=0,改变方差sigma (0.5, 1, 2, 4)
%===================================================================
% 文件名 e_gauss.m
% 高斯曲线
clear;
a=-6;sigma=1; % 均值a=-6
x=-10:0.0001:10;
figure(1)
y=(1/((sqrt(2*pi))*sigma))*exp(-((x-a).^2)/(2*sigma.^2));
plot(x,y,'b','LineWidth',1.5);
hold on; % 三个图形画在一张图上
a=6;sigma=1; %均值a=+6
x=-10:0.0001:10;
y=(1/((sqrt(2*pi))*sigma))*exp(-((x-a).^2)/(2*sigma.^2));
plot(x,y,'-g','LineWidth',1.5);
a=0;sigma=1; % 均值a=0
x=-10:0.0001:10;
y=(1/((sqrt(2*pi))*sigma))*exp(-((x-a).^2)/(2*sigma.^2));
plot(x,y,'r','LineWidth',1.5);grid;
xlabel('方差 sigma=1');
ylabel('f(x)');
legend('a=-6','a=+6','a=0')
title('正态随机过程一维概率密度函数(高斯曲线)');grid;
hold off % 关闭
grid;
%=========================================================
% 均值不变,改变-sigma大小
figure(2)
a=0;sigma=1/2; % 方差sigma=0.5
y=(1/((sqrt(2*pi))*sigma))*exp(-((x-a).^2)/(2*sigma.^2));
plot(x,y,'r','LineWidth',1.5);grid;
hold on % 三个图形画在一张图上
a=0;sigma=1; % 方差sigma=1
x=-10:0.0001:10;
y=(1/((sqrt(2*pi))*sigma))*exp(-((x-a).^2)/(2*sigma.^2));
plot(x,y,'b','LineWidth',1.5);grid;
a=0;sigma=2; % 方差sigma=2
x=-10:0.0001:10;
y=(1/((sqrt(2*pi))*sigma))*exp(-((x-a).^2)/(2*sigma.^2));
plot(x,y,'m','LineWidth',1.5);grid;
a=0;sigma=4; % 方差sigma=4
x=-10:0.0001:10;
y=(1/((sqrt(2*pi))*sigma))*exp(-((x-a).^2)/(2*sigma.^2));
plot(x,y,'k','LineWidth',1.5);grid;
xlabel('均值 a=0');
ylabel('f(x)');grid;
legend('sigma=0.5','sigma=1','sigma=2','sigma=4')
title('正态随机过程一维概率密度函数(高斯曲线)');grid;
hold off; % 关闭
grid;
%=========================================================