Skip to main content

BinarySimilarity

Trait BinarySimilarity 

Source
pub trait BinarySimilarity
where Self: Sized,
{ // Required methods fn hamming(a: &[Self], b: &[Self]) -> Option<Distance>; fn jaccard(a: &[Self], b: &[Self]) -> Option<Distance>; }
Expand description

BinarySimilarity provides trait methods for computing similarity metrics that are commonly used with binary data vectors, such as Hamming distance and Jaccard index.

The methods accept two slices of binary data and return an Option indicating the computed similarity or distance, with None returned if the slices differ in length.

Required Methods§

Source

fn hamming(a: &[Self], b: &[Self]) -> Option<Distance>

Computes the Hamming distance between two binary data slices. The Hamming distance between two strings of equal length is the number of bits at which the corresponding values are different.

Source

fn jaccard(a: &[Self], b: &[Self]) -> Option<Distance>

Computes the Jaccard index between two bitsets represented by binary data slices. The Jaccard index, also known as the Jaccard similarity coefficient, is a statistic used for gauging the similarity and diversity of sample sets.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl BinarySimilarity for u8

Source§

fn hamming(a: &[Self], b: &[Self]) -> Option<Distance>

Source§

fn jaccard(a: &[Self], b: &[Self]) -> Option<Distance>

Implementors§