Академический Документы
Профессиональный Документы
Культура Документы
Algorithm
d=
(xi yi )2
(1.1)
i=1
dsq = (xi yi )2
(1.2)
i=1
The Manhattan measure calculates a distance between points based on a grid and is illustrated in Figure 1.1.
Euclidean measure
Manhattan measure
Figure 1.1: Comparision between the Euclidean and the Manhattan measure.
For applications in speech processing the squared Euclidean distance is widely used.
20
15
10
10
15
20
20
15
10
10
15
20
Figure 1.2: Example of signal data made from Gaussian White Noise.
20
15
10
10
15
20
20
15
10
10
15
20
Figure 1.3: The signal data are seperated into seven clusters. The centroids are
marked with a cross.
Cluster
7
0
0.2
0.4
0.6
Silhouette Value
0.8
Figure 1.4: The Silhouette diagram shows how well the data are seperated
into the seven clusters. If the distance from one point to two centroids is the
same, it means the point could belong to both centroids. The result is a conflict
which gives a negative value in the Silhouette diagram. The positive part of
the Silhuoette diagram, shows that there is a clear seperation of the points
between the clusters.
close all
clear all
clc
Limit = 2 0 ;
X = [ 1 0 randn ( 4 0 0 , 2 ) ; 1 0 randn ( 4 0 0 , 2 ) ] ;
p l o t ( X ( : , 1 ) ,X ( : , 2 ) , k . )
length ( X ( : , 1 ) )
figure
%i = 1 ;
k=1;
f o r i = 1 : length (X ( : , 1 ) )
i f ( s q r t (X( i , 1 ) ^2+X( i , 2 ) ^2) ) > Limit ;
X( i , 1 ) = 0 ;
X( i , 2 ) = 0 ;
else
Y( k , 1 ) =X( i , 1 ) ;
Y( k , 2 ) =X( i , 2 ) ;
k=k + 1 ;
end
end
p l o t ( Y ( : , 1 ) ,Y ( : , 2 ) , k . )
figure
[ cidx , c t r s ] = kmeans ( Y , 7 , d i s t , sqEuclidean , rep , 5 , disp ,
f i n a l , EmptyAction , s i n g l e t o n ) ;
27
28 p l o t ( Y( c i d x ==1 ,1) ,Y( c i d x ==1 ,2)
29 Y( c i d x ==2 ,1) ,Y( c i d x ==2 ,2) , b .
30
31 hold on
32 p l o t ( Y( c i d x ==3 ,1) ,Y( c i d x ==3 ,2)
;
33
34 hold on
35 p l o t ( Y( c i d x ==5 ,1) ,Y( c i d x ==5 ,2)
;
36
37 hold on
38 p l o t ( Y( c i d x ==7 ,1) ,Y( c i d x ==7 ,2)
39
40 f i g u r e
, r. , ...
, c t r s ( : , 1 ) , c t r s ( : , 2 ) , kx ) ;
, y . ,Y( c i d x ==4 ,1) ,Y( c i d x ==4 ,2) , g . )
, k . ) ;