plotting data to get mahalanobis and eucledian distance
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I get example from book to calculate mahalanobis and eucledian distance as shown below, but the book doesn't provide ilustration, so i trying to make plotting data point of gaussian distribution of two class based on its mean and covariance value . But I am not convident with the result that i got. Since the data that i generate from information quite complicated, and end up confusing me with the result. The result says data point x classifies in first class based on euclidean distance and classified in second class based on mahalanobis distance.
Here the example of the book
% 1. Utilize function euclidean_classifier by typing
x=[0.1 0.5 0.1]';
m1=[0 0 0]';
m2=[0.5 0.5 0.5]';
m=[m1 m2];
z_euc=euclidean_classifier(m,x)
% 2. Use function mahalanobis_classifier
x=[0.1 0.5 0.1]';
m1=[0 0 0]';
m2=[0.5 0.5 0.5]';
m=[m1 m2];z
S=[0.8 0.01 0.01;
0.01 0.2 0.01;
0.01 0.01 0.2];
z_mahal=mahalanobis_classifier(m,S,x)
Here my attemp to ilustrate the distribution of point in 3D
me =m1';
s = 1;
pdf1 = bsxfun(@plus,me,s.*randn(500,3));
plot3(pdf1(:,1),pdf1(:,2),pdf1(:,3),'.r')
M = mean(pdf1,1)
S = std(pdf1,1)
hold on
pdf2 = bsxfun(@plus,m2',s.*randn(500,3));
plot3(pdf2 (:,1),pdf2 (:,2),pdf2 (:,3),'.b')
hold on
plot3(x(1),x(2),x(3),'og',MarkerFaceColor='g')
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Descriptive Statistics and Visualization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!