Distance Metric Explorer
Compare Euclidean, Manhattan, cosine, Jaccard, and Hamming metrics on vectors, sets, or bitstrings.
About this tool
Compare two small numeric vectors, true token sets or bitstrings. Results update locally as you type; only applicable metrics are shown. Definitions reveals their formulas. Example restores the current tab’s inputs. CSV contains the parsed inputs, unrounded results and any undefined-cosine reason.
Vectors: 1–32 decimal components, separated by spaces, commas or semicolons; decimal point and scientific notation are accepted. A comma separates components, it is not a decimal mark. Equal dimensions are required. Nonzero magnitudes 1e−300–1e300; 8,000 characters per input. Euclidean is straight-line distance; Manhattan sums absolute component differences. Distances use input units and grow with scale, not a similarity percentage. Hamming counts unequal component values using exact numeric equality, without a tolerance.
Sets: whitespace/comma/semicolon-separated tokens, at most 500 before removing duplicates; empty input is the empty set. Tokens are NFC-normalized and case-sensitive, punctuation within a token is retained. Order and repetitions have no effect. Jaccard is intersection/union (two empty sets: similarity 1). Set cosine uses binary presence vectors, not word frequencies. For {a,b} and {b,c}, Jaccard is 1/3 and cosine 1/2. For lexical text or images use Similarity Search.
Bits: 1–128 zeroes/ones, whitespace ignored, equal lengths. Hamming counts differing positions; similarity is 1−count/length. Euclidean equals √Hamming and Manhattan equals Hamming. Jaccard compares positions of ones, ignoring shared zeroes; all-zero pairs have Jaccard similarity 1. Cosine uses the bit vectors. 100/010 gives Hamming 2, similarity 1/3, Jaccard 0.
Cosine measures direction, independent of positive scale: similarity −1 to 1, distance 1−similarity (0 to 2). Opposite signed vectors give similarity −1 and distance 2; orthogonal nonzero vectors similarity 0 and distance 1; an empty set or zero vector has no defined direction and shows a dash. Cosine distance is not a metric satisfying the triangle inequality in general. A dash in the similarity column for Euclidean/Manhattan means no arbitrary conversion is invented. Finite floating-point arithmetic and eight significant display digits; CSV retains full precision. This compares coordinates/tokens, not semantic meaning.