stdlib-js / stdlib-js/stdlib

[RFC]: Bray-Curtis distance between two strided arrays

Open
#834 3 comments 0 reactions 0 assignees View on GitHub
Accepted Feature Native Addons RFC
Dominant language
JavaScript
Stars
6k
Forks
1.3k
Avg merge
1d 3h
Merged PRs (30d)
611

Description

### Description

This RFC proposes adding a function to calculate the Bray-Curtis distance between two strided arrays.

Package: `@stdlib/math/strided/distances/braycurtis`

The function should have the following signature `braycurtis( N, x, strideX, y, strideY )`.

- N: Number of elements
- x: First array
- strideX: Stride for the first array
- y: Second array
- strideY: Stride for the second array

The function should return the Bray-Curtis distance between the two arrays. It is calculated by

```
d = sum( |x_i - y_i| ) / sum( |x_i + y_i| )
```

where `x_i` and `y_i` are corresponding elements from the two arrays.

### References

- [Bray-Curtis distance](https://en.wikipedia.org/wiki/Bray%E2%80%93Curtis_dissimilarity)
- [SciPy](https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.braycurtis.html#scipy.spatial.distance.braycurtis)

### Related Issues

None.

### Questions

No.

### Other

No.

### Checklist

- [X] I have read and understood the [Code of Conduct](https://github.com/stdlib-js/stdlib/blob/develop/CODE_OF_CONDUCT.md).
- [X] Searched for existing issues and pull requests.
- [X] The issue name begins with `RFC:`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.