Expand description
§Distances (v1.7.1)
Fast and generic distance functions for high-dimensional data.
§Usage
Add this to your project:
> cargo add distances@1.7.1
Use it in your project:
use distances::Number;
use distances::vectors::euclidean;
let a = [1.0_f32, 2.0, 3.0];
let b = [4.0_f32, 5.0, 6.0];
let distance: f32 = euclidean(&a, &b);
assert!((distance - (27.0_f32).sqrt()).abs() < 1e-6);
§Features
-
A
Number
trait to abstract over different numeric types.-
Distance functions are generic over the return type implementing
Number
. -
Distance functions may also be generic over the input type being a collection of
Number
s.
-
Distance functions are generic over the return type implementing
- SIMD accelerated implementations for float types.
-
Python bindings with
maturin
andpyo3
. -
no_std
support.
§Available Distance Functions
-
Vectors (high-dimensional data):
-
euclidean
-
squared_euclidean
-
manhattan
-
chebyshev
-
minkowski
- General Lp-norm.
-
minkowski_p
- General Lp-norm to the
p
th power.
- General Lp-norm to the
-
cosine
-
hamming
-
canberra
-
bray_curtis
-
pearson
1.0 - r
wherer
is the Pearson Correlation Coefficient
-
-
Probability distributions:
-
wasserstein
-
bhattacharyya
-
hellinger
-
-
String data, e.g. for genomic sequences:
-
levenshtein
-
needleman_wunsch
-
smith_waterman
-
hamming
- Normalized versions of the above.
-
-
Sets:
-
jaccard
-
dice
-
kulsinski
-
hausdorff
-
-
Graphs:
-
tanamoto
-
- Time series:
§Contributing
Contributions are welcome, encouraged, and appreciated! See CONTRIBUTING.md.
§License
Licensed under the MIT license.
Re-exports§
pub use number::Number;
Modules§
- The
Number
trait is used to represent numbers of different types. - Distance functions for sets.
- Provides simd-accelerated euclidean distance functions for vectors.
- String distance metrics.
- Distance functions for vectors.
Constants§
- The version of the crate.