preview

Cosine Correlation Essay

Satisfactory Essays
x = (1, 1, 1, 1), y = (2, 2, 2, 2) cosine, correlation, Euclidean
COSINE
cos (x, y)= (x.y)/(||x|| ||y||)

x.y = 1*2 + 1*2 + 1*2 + 1*2 = 8
||x||= √(1*1 + 1*1 + 1*1 + 1*1) = √4 = 2
||y||= √(2*2 + 2*2 + 2*2 + 2*2) = √16 = 4
Hence, cos (x,y) = 8/(2*4)  1

CORRELATION corr(x, y) = (covariance(x,y))/([standard deviation(x) * standard deviation(y)])

Mean of x = (1+1+1+1)/4 = 1 ; Mean of y = (2+2+2+2)/4 = 2 covariance(x,y) = 1/(4-1) * [(1-1)(2-2) + (1-1)(2-2) + (1-1)(2-2) + (1-1)(2-2)] = 0
Standard deviation (x) = √(1/((4-1))* {(1-1)^2 + (1-1)^2 + (1-1)^2 + (1-1)^2} ) = 0
Standard deviation (y) =√(1/((4-1))* {(2-2)^2 + (2-2)^2 + (2-2)^2 + (2-2)^2}) = 0
Hence, corr (x,y)= 0/0  Not Defined

EUCLIDEAN d(x, y) = √((1-2)^2 +
…show more content…
as 1 and y was 1
J= 0/(2+2+0) = 0

Hence, Jaccard  0

(c) x = (0,-1,0,1), y = (1,0,-1,0) cosine, correlation, Euclidean

COSINE cos (x, y)= (x.y)/(||x|| ||y||)

x.y = 0*1 + (-1)*0 + 0*(-1) + 1*0 = 0
||x||= √(0*0 + (-1)*(-1) + 0*0 + 1*1) = √2
||y||= √(1*1 + 0*0 + (-1)*(-1) + 0*0) = √2
Hence, cos (x,y) = 0/2  0

CORRELATION corr(x, y) = (covariance(x,y))/([standard deviation(x) * standard deviation(y)])

Mean of x = (0+(-1)+0+1)/4 = 0
Mean of y = (1+0+(-1)+0)/4 = 0 covariance(x,y) = 1/(4-1) * [(0-0)(1-0) + (-1-0)(0-0) +(0-0)(-1-0) +(1-0)(0-0)] = 1/3 * 0 = 0
Since Covariance == 0 ;
Hence, corr (x,y )  0

EUCLIDEAN d(x, y) = √((0-1)^2 + (-1-0)^2 + (0+1)^2 + (1-0)^2) = √4 = 2
Hence, Euclidean Distance  2

(d) x = (1,1,0,1,0,1), y = (1,1,1,0,0,1) cosine, correlation, Jaccard

COSINE cos (x, y)= (x.y)/(||x|| ||y||)

x.y = 1*1 + 1*1 + 0*1 + 1*0 + 0*0 + 1*1 = 3
||x||= √(1*1 + 1*1 + 0*0 + 1*1 + 0*0 + 1*1) = √4 =2
||y||= √(1*1 + 1*1 + 1*1 + 0*0 + 0*0 + 1*1) = √4 = 2
Hence, cos (x,y) = 3/(2*2)  0.75

CORRELATION corr(x, y) = (covariance(x,y))/([standard deviation(x) * standard deviation(y)])

Mean of x = (1+1+0+1+0+1)/6 = 4/6
Mean of y = (1+1+1+0+0+1)/6 = 4/6 covariance(x,y) =
= 1/(6-1) * [(1-4/6)(1-4/6) + (1-4/6)(1-4/6) +(0-4/6)(1-4/6) +(1-4/6)(0-4/6) + (0-4/6)(0-4/6) + (1-4/6)(1-4/6) ]
= 1/15

Standard deviation (x) =√(1/((6-1))* {(1-4/6)^2 + (1-4/6)^2 + (0-4/6)^2 + (1-4/6)^2 + (0-4/6)^2 +
Get Access