📄 example1_3.asv
字号:
% Likelyhood demonstration
%X3 is an observation created by a Gaussian distribution pdf with
%mu=[730 1090] and
%sigma=[8000 8400; 8400 18500]
%Given four different pdf to calculate the likelihood for each of them
%
%mu1=[730 1090] and
%sigma1=[8000 0; 0 8000]
%
%mu2=[730 1090] and
%sigma2=[8000 8400; 8400 8000]
%
%mu3=[730 1090] and
%sigma3=[8000 8400; 8400 18500]
%
%mu4=[270 1690] and
%sigma4=[8000 8400; 8400 18500]
%
%Change the mu and sigma for above pdf and try it again!
%and find the largest logLike1 from them! Why?
clear all;
%load Xdata.mat;
%whos;
%X3
N1=10000;
mu=[730 1090];
sigma_3=[8000 8400; 8400 18500];
X3 = randn(N1,2)*sqrtm(sigma_3)+repmat(mu, N1, 1);
%save xdata.mat X3;
% Likelihood of each Gaussian model
N=size(X3,1)
% Try to change the mu and sigma!
mu_1=[730 1090];
sigma_1=[8000 8400;8400 18500];
logLike1=0;
for i = 1:N;
logLike1=logLike1+(X3(i,:)-mu_1)*inv(sigma_1)*(X3(i,:)-mu_1)';
end;
logLike1= -0.5*(logLike1+N*log(det(sigma_1))+2*N*log(2*pi))
%gausview(X3,mu_1,sigma_1, 'Sample X3');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -