Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/antononcube/raku-math-distancefunctions

Raku package for the computation of various distance functions.
https://github.com/antononcube/raku-math-distancefunctions

bray-curtis-distance canberra-distance cosine-distance distance-functions euclidean-distance hamming-distance manhattan-distance raku

Last synced: about 2 months ago
JSON representation

Raku package for the computation of various distance functions.

Awesome Lists containing this project

README

        

# Math::DistanceFunctions

Raku package with a collection of mathematical distance functions and a corresponding role.

The content of this package was "factored out" from
["ML::Clustering"](https://raku.land/zef:antononcube/ML::Clustering), [AAp1].

Faster versions of these functions are implemented in
["Math::DistanceFunctions::Native"](https://github.com/antononcube/Raku-Math-DistanceFunctions-Native), [AAp2].

A special package has the "edit distance" (aka Damerau-Levenshtein distance) -- see
["Math::DistanceFunctions::Edit"](https://github.com/antononcube/Raku-Math-DistanceFunctions-Edit), [AAp3].

------

## Installation

From Zef ecosystem:

```
zef install Math::DistanceFunctions
```

From GitHub:

```
zef install https://github.com/antononcube/Raku-Math-DistanceFunctions.git
```

-----

## Usage examples

```perl6
use Math::DistanceFunctions;

my @v1 = 10.rand xx 10;
my @v2 = 2.rand xx 10;

my @funcs = [
:&bray-curtis-distance,
:&canberra-distance,
:&chessboard-distance,
:&cosine-distance,
:&dot-product,
:&euclidean-distance,
:&hamming-distance,
:&manhattan-distance,
:&squared-euclidean-distance
];

for @funcs -> $p {
say "{$p.key} : {$p.value.(@v1, @v2)}";
}
```

-----

## References

[AAp1] Anton Antonov, [ML:Clustering Raku package](https://github.com/antononcube/Raku-ML-Clustering), (2022), [GitHub/antononcube](https://github.com/antononcube).

[AAp2] Anton Antonov,
[Math::DistanceFunctions::Edit Raku package](https://github.com/antononcube/Raku-Math-DistanceFunctions-Edit),
(2024),
[GitHub/antononcube](https://github.com/antononcube).

[AAp3] Anton Antonov,
[Math::DistanceFunctions::Native Raku package](https://github.com/antononcube/Raku-Math-DistanceFunctions-Native),
(2024),
[GitHub/antononcube](https://github.com/antononcube).