written 5.6 years ago by | modified 4.6 years ago by |
ii) Find Hamming Distance between 110011 & 010101 and 11001 & 01011
iii) Compute the cosines of the angles between (3,-1,2) and (-2,3,1).
written 5.6 years ago by | modified 4.6 years ago by |
ii) Find Hamming Distance between 110011 & 010101 and 11001 & 01011
iii) Compute the cosines of the angles between (3,-1,2) and (-2,3,1).
written 5.6 years ago by |
(i) Jaccard distance
A = { 1,2,3,4 } and B = {2,3,5,7}
d(A,B) = 1 - J(A,B)
J(A,B) = $\frac{A \cap B}{A \cup B} = \frac{ | \{2,3\} | }{| \{1,2,3,4,5,7\} | } = \frac{2}{6} = \frac{1}{3}$
d(A,B) = $1 - \frac{1}{3} = \frac{2}{3}$
A = {a,a,a,b} and B = {a,a,b,b,c}
J(A,B) = $ \frac{ | \{a,b\} | }{| \{a,b,c\} | } = \frac{2}{3} $
d(A,B) = $1 - \frac{2}{3} = \frac{1}{3}$
(ii) Hamming distance
A = 110011, B = 010101
H(A,B) = no. of item in which A,B differ = 3
A = { 11001 }, B = { 01011 }
H(A,B) = 2
(iii) Cosine distance
A = (3,-1,2), B = (-2,3,1)
cosine (AiB) = $\frac{A * B}{||A|| * ||B||}$
$\begin{aligned} A*B &= 3 * (-2) + (-1) * 3 + 2 * 1 \\ &= -6 + 3 + 2 \\ &= -7 \end{aligned}$
$||A|| = \sqrt{3^2 + (-1)^2 + (2)^2} = \sqrt{14}$
$||B|| = \sqrt{(-2)^2 + (3)^2 + (1)^2} = \sqrt{14}$
$||A|| . ||B|| = \sqrt{14} . \sqrt{14} = 14$
cosine (A,B) = $\frac{-7}{14} = \frac{-1}{2} = -0.5$
Distance (A,B) = $cos^{-1} (-0.5)$