[ home ] [ math / cs / ai / phy / as / chem / bio / geo ] [ civ / aero / mech / ee / hdl / os / dev / web / app / sys / net / sec ] [ med / fin / psy / soc / his / lit / lin / phi / arch ] [ off / vg / jp / 2hu / tc / ts / adv / hr / meta / tex ] [ chat ] [ wiki ]

Viewing source code

The following is the source code for post >>>/math/115

>>113
I'm a dumbass, it's actually \underline{minkowski distance}

Anyways, for the euclidian distance, apparently you do:
\math{\sqrt{ (x_1-y_1)^2+(x_2-y_2)^2}}
or for those playing along in calc, \icode{=SQRT((B$3-B3)^2+(C$3-C3)^2)} and apply to the appropriate cells.

\math{ \begin{bmatrix}
0.0 & 2.8&3.2&5.1\\
2.8&0.0&1.4&3.2\\
3.2&1.4&0.0&2.0\\
5.1&3.2&2.0&0.0
\end{bmatrix}
}

Since i was working in calc, the table containing the data spans over the \icode{B3:C6} range

Then, for the minkowski distance, there's something called the P value, and if it's equal to 1, then it becomes the manhattan distance, so in this example the equation would be \math{|x1-y1|\ +\ |x2-y2|}
and the corresponding calc formula for a particular cell (i'm not saying which one hehe)
\icode{=(($B$3-$B3)^1+($C$3-$C3)^1)^(1/RIGHT($E$14,1))}

,bmat 0&0&2&4\\0&0&2&4\\-2&-2&0&2\\-4&-4&-2&0


And for the cosine similarity or distance idk, just do a vector dot product \math{\frac{x \cdot y}{|x|\cdot|y|}}
This time it was a bit more difficult in calc, and the formula for the left upper cell is \icode{=SUMPRODUCT(B$3:C$3,B3:C3)/(SQRT(SUMSQ(B$3:C$3))*SQRT(SUMSQ(B3:C3)))}

,bmat 1.00&0.00&0.32&0.20\\0.00&1.00&0.95&0.98\\0.32&0.95&1.00&0.99\\0.20&0.98&0.99&1.00\\


Cool.