Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Having a pair of vectors where its elements are complex, is that possible to calculate the cosine similarity between these two vectors to see how similar they are?, and if the result of this calculation is another complex number, What should i do with this result?, I have applied the norm, is that correct?.

Tnaks for your comments!

share|improve this question
    
Could you please define "cosine similarity" and "similar vectors"...? –  DonAntonio Jan 9 '13 at 15:04
    
@DonAntonio, someone has explained about that, look the answers!. Thanks for your interest. –  Gina Torres Jan 10 '13 at 10:16
    
sigo sin entender qué es "similitud (similaridad) de vectores o de cosenos". Si pudieras darme un lugar donde se define porque, al parecer, no es una definición usual, y la respuesta abajo no lo menciona de una manera matemática. Por cierto, es una buena idea votar positivamente una respuesta que te ha ayudado, aunque no necesariamente tienes que aceptarla como la favorita tuya (con la "V" verde). Observa también que la pregunta es sumamente elemental y muchos aquí tenemos doctorado, maestría y demás, así que probablemente la pregunta sea poco clara. Saludos. –  DonAntonio Jan 10 '13 at 13:38
    
Disculpas. Le envìo uno de los lugares donde lo puede encontrar aipo.es/articulos/1/12434.pdf en la pàgina 47 al final se encuentra la formulaciòn. Gracias. –  Gina Torres Jan 11 '13 at 13:09

1 Answer 1

up vote 1 down vote accepted

It sounds like you want to take the dot product such that a vector dotted with itself gives the magnitude squared norm. For real vectors $\mathbf{x}$ and $\mathbf{y}$ this is $$\langle\mathbf{x},\mathbf{y}\rangle := \mathbf{x}^\top \mathbf{y}$$

Note that a norm should always return a non-negative real value so that $$\langle\mathbf{x},\mathbf{x}\rangle \ge 0$$

Note also that if $\mathbf{x}$ has complex values this definition fails to be a norm. To see this consider $\mathbf{x}^\top = (i,0,0,\dots)$ giving $$\mathbf{x}^\top \mathbf{x} = -1$$

Thus for complex numbers the norm is slightly different. To be a norm in the complex field, define the norm as $$\langle\mathbf{x},\mathbf{y}\rangle := \mathbf{x}^\dagger \mathbf{y}$$ Where the difference is that instead of the transpose, it is the transpose and complex conjugate. In that case for the example $\mathbf{x}^\top = (i,0,0,\dots)$ \begin{align} \mathbf{x}^\dagger \mathbf{x} &= (-i,0,0,\dots) (i,0,0,\dots)^\top\\ & = -ii \\ &= -(-1)\\ & = 1 \\ \end{align}

In terms of your desire to measure their "similarity", I am supposing you want the angle between them, which (for reals) requires solving the formula $$\cos\theta = \frac{\mathbf{x}^\top \mathbf{y}}{(\mathbf{x}^\top\mathbf{x})(\mathbf{y}^\top\mathbf{y})}$$

Or more simply for $\vert \mathbf{x} \vert = 1$ and $\vert \mathbf{y} \vert = 1$

$$\cos\theta = \mathbf{x}^\top \mathbf{y}$$

The magnitude on the right will be between zero and one. Zero means that the two vectors are orthogonal (90 degrees or $\pi\over 2$). One means they are scalar multiples of each other.

For complex, the magnitude still gives the "similarity" between them, where the complex angle gives the complex phase factor required to fully reach that similarity. In other words, if your result is $\cos\theta=-i$, then $i\mathbf{x}$ is a real scalar multiple of $\mathbf{y}$.

share|improve this answer
    
Thanks for your answer, so you mean if i calculate the cosine similarity between two vectors which elements are complex (a+bi) and if I obtain a complex c+di, if c es very near to 1 the vectors are scalar multiples of each other, and d gives the complex phase factor to fully reach the similarity, right?. So if i obtain for example(0.22203+0.87708i) calculating the cosine similarity of two vectors x_red=(-0.0003 + 0.0008i;0.0015 - 0.0012i) and x_compl=1.0e-007 *(-0.0317 + 0.0871i;0.1674 - 0.1330i), how similar could i say they are?. –  Gina Torres Jan 10 '13 at 9:57
1  
Magnitude squared is the real component squared plus the imaginary component squared. It is the pythagorean theorem on the complex plane. $\vert a + ib \vert = \sqrt{a^2 + b^2}$ –  adam W Jan 10 '13 at 14:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.