Vector Similarity Calculator
Calculate distance and similarity between numeric vectors using methods including cosine, euclidean, jaccard, and more.
Input
Output
Readme
What is vector similarity?
Vector similarity measures how alike two vectors are in a multi-dimensional space. Vectors are ordered lists of numbers that represent data points — they appear in machine learning embeddings, recommendation systems, natural language processing, image recognition, and scientific computing. Comparing two vectors tells you how close or related the underlying data points are.
Two core concepts are used:
- Similarity: A score indicating how alike two vectors are. Higher values typically mean more similar (e.g., cosine similarity of 1 means identical direction).
- Distance: A measure of how far apart two vectors are. Lower values typically mean more similar (e.g., Euclidean distance of 0 means identical vectors).
Tool description
This tool computes the similarity or distance between two numeric vectors using over 50 well-known methods from information theory, statistics, and geometry. Enter two vectors, choose a method from the similarity or distance tab, and the result is computed instantly in your browser.
Examples
Input
Vector A: 1, 2, 3
Vector B: 4, 5, 6| Method | Result |
|---|---|
| Cosine similarity | 0.9746318461970762 |
| Euclidean distance | 5.196152422706632 |
| Manhattan distance | 16.5 |
Accepted input formats
All of the following are equivalent:
1, 2, 3
[1, 2, 3]
(1 2 3)
1;2;3Features
- 50+ methods — choose from distances (Euclidean, Manhattan, Chebyshev, Cosine, Kullback-Leibler, Jensen-Shannon, and more) or similarities (Cosine, Jaccard, Dice, Tanimoto, and more)
- Flexible input — accepts comma-, space-, or semicolon-separated values with or without brackets
- Instant results — all computation runs client-side with no data sent to a server
Supported methods
Similarity methods
| Method | Description |
|---|---|
| Cosine | Measures the angle between two vectors; widely used in NLP and recommendation systems |
| Kumar-Hassebrook | Generalized similarity combining Jaccard and cosine |
| Dice | Twice the intersection divided by the sum of element counts |
| Tanimoto | Extended Jaccard coefficient for continuous vectors |
| Intersection | Sum of the element-wise minimums |
| Czekanowski | Ratio of twice the sum of minimums to the total sum |
| Motyka | Intersection divided by the sum of all elements |
| Kulczynski | Harmonic mean of precision and recall-like ratios |
| Squared Chord | Based on the square roots of the element products |
| Pearson | Linear correlation coefficient between the two vectors |
Distance methods
| Method | Description |
|---|---|
| Euclidean | Straight-line distance in n-dimensional space |
| Squared Euclidean | Euclidean distance without the square root |
| Manhattan (City Block) | Sum of absolute element-wise differences |
| Chebyshev | Maximum absolute difference across all dimensions |
| Canberra | Weighted Manhattan distance sensitive to values near zero |
| Sørensen | Sum of absolute differences divided by sum of all values |
| Gower | Normalized mean of absolute differences |
| Soergel | Ratio of absolute differences to element-wise maximums |
| Lorentzian | Sum of natural logs of absolute differences plus one |
| Clark | Weighted distance using absolute differences over sums |
| Wave Hedges | Sum of absolute differences divided by element-wise maximums |
| Czekanowski | Distance form of the Czekanowski coefficient |
| Motyka | Distance form of the Motyka coefficient |
| Kulczynski | Distance form of the Kulczynski coefficient |
| Tanimoto | Distance form of the Tanimoto coefficient |
| Ruzicka | Complement of the Ruzicka similarity |
| Inner Product | Negative dot product as a distance measure |
| Harmonic Mean | Distance based on harmonic means of element pairs |
| Jaccard | Proportion of non-matching components |
| Dice | Distance form of the Dice coefficient |
| Fidelity | Based on the square root of element products (Bhattacharyya-related) |
| Bhattacharyya | Measures overlap between two probability distributions |
| Hellinger | Square root of the Bhattacharyya distance |
| Matusita | Square root of half the sum of squared differences of square roots |
| Squared Chord | Distance form of the Squared Chord coefficient |
| Pearson | Distance form of the Pearson correlation coefficient |
| Neyman | Chi-squared-type divergence |
| Squared | Squared chi-squared distance |
| Probabilistic Symmetric | Symmetric version of the chi-squared divergence |
| Divergence | Doubly weighted squared distance |
| Additive Symmetric | Average of Neyman and Pearson chi-squared divergences |
| Kullback-Leibler | Information-theoretic divergence between distributions |
| Jeffreys | Symmetric Kullback-Leibler divergence |
| K Divergence | Asymmetric divergence based on average distribution |
| Topsøe | Twice the Jensen-Shannon divergence |
| Jensen-Shannon | Smoothed, symmetric version of Kullback-Leibler |
| Jensen Difference | Based on the Jensen inequality for convex functions |
| Taneja | Arithmetic-geometric mean divergence |
| Kumar-Johnson | Based on squared differences of even powers |
| Intersection | Complement of the intersection similarity |
| Average (City Block + Chebyshev) | Mean of Manhattan and Chebyshev distances |
How it works
The tool parses each vector input into a sequence of numbers, strips optional brackets, and splits on commas, spaces, or semicolons. It then passes both arrays to the selected function from the ml-distance library, which performs the computation in pure JavaScript. Both vectors must have the same number of dimensions; otherwise the tool shows a validation error.
Limitations
- Some methods (e.g., Kullback-Leibler, Bhattacharyya) require all values to be strictly positive and sum to 1 (probability distributions). Using arbitrary vectors may produce
InfinityorNaN, which the tool treats as a computation error. - Very large vectors (thousands of dimensions) are supported but may cause a brief delay depending on the chosen method.