Zhankun Luo
PUID: 0031195279
Email: luo333@pnw.edu
Fall-2018-ECE-59500-009
Instructor: Toma Hentea
Homework 1
文章目录
Problem
Problem 2.7
(a) classify the feature vector [1.6; 1.5]
%% Problem 2.7 : calculate parameters
sigma = [1.2 0.4; 0.4 1.8];
mu1 = [0.1; 0.1];
mu2 = [2.1; 1.9];
mu3 = [-1.5; 1.9];
w1 = sigma \ mu1;
w2 = sigma \ mu2;
w3 = sigma \ mu3;
w10 = log(1/3) - 0.5 * mu1' * w1;
w20 = log(1/3) - 0.5 * mu2' * w2;
w30 = log(1/3) - 0.5 * mu3' * w3;
%% get exact value of g_i(x) of x
x = [1.6; 1.5];
g1 = w1' * x + w10
g2 = w2' * x + w20
g3 = w3' * x + w30
result
g1 = -0.9321
g2 = 0.1279
g3 = -4.4611
conclusion
g 2 ( x ) > g 1 ( x ) ; g 2 ( x ) > g 3 ( x ) g_2(x) > g_1(x) ; g_2(x) > g_3(x) g2(x)>g1(x);g2(x)>g3(x) ==> P ( ω 2 ∣ x ) > P ( ω 1 ∣ x ) , P ( ω 3 ∣ x ) P(\omega_2|x) > P(\omega_1|x), P(\omega_3|x) P(ω2∣x)>P(ω1∣x),P(ω3∣x)
Thus x x x belongs to the second class: x → ω 2 x \rightarrow \omega_2 x→ω2
(b) draw the curves of equal Mahalanobis distance from [2.1; 1.9]
%% Problem 2.7 (b)
% draw the curves of equal Mahalanobis distance from [2.1; 1.9]
x = -2:0.2:6;
y = -2:0.2:6;
mu = [2.1; 1.9];
sigma = [1.2 0.4; 0.4 1.8];
[X,Y] = meshgrid(x,y);
vector(:, :, 1) = X - mu(1) * ones(41, 41);
vector(:, :, 2) = Y - mu(2) * ones(41, 41);
for i = 1:41
for j = 1:41
temp = vector(i, j, :);
Temp = reshape(temp, 2, 1);
tempZ = sqrt(Temp' * (sigma \ Temp));
Z(i, j) = tempZ;
end
end
figure
contour(X, Y, Z, 'ShowText', 'on')
Curves of equal Mahalanobis distance from [2.1; 1.9]