fslaborg / FSharp.Stats

statistical testing, linear algebra, machine learning, fitting and signal processing in F#
https://fslab.org/FSharp.Stats/
Other
205 stars 54 forks source link

minkowski distance #308

Closed s-weil closed 8 months ago

s-weil commented 9 months ago

Please reference the issue(s) this PR is related to

Closes #182

Please list the changes introduced in this PR

Description

Implement the Minkowski distance of order p in several versions, following https://en.wikipedia.org/wiki/Minkowski_distance and #182

[Required] please make sure you checked that

[Optional]

s-weil commented 9 months ago

Note that in a separate issue, one could try to tackle code duplications in the src and tests of distance metrics. This however may affect performance and must be conducted carefully.

s-weil commented 9 months ago

Regarding that p could also be 0 < p < 1 and restricting it to be an integer, I may have been a bit too strict on the given signature specified in https://github.com/fslaborg/FSharp.Stats/issues/296 Also it was specified to be an integer in https://en.wikipedia.org/wiki/Minkowski_distance

Happy to change it to a float for a more generic version. It may affect performance though.

If it becomes a float, I can also handle the case when 0 < p <1 by removing the exponent 1/p as described in Wiki.

s-weil commented 9 months ago

Pushed the feedback.

The order p is now a float and the case 0 < p < 1 is covered

codecov-commenter commented 8 months ago

Codecov Report

Merging #308 (9d38186) into developer (1e680b1) will increase coverage by 0.27%. Report is 12 commits behind head on developer. The diff coverage is 79.57%.

@@              Coverage Diff              @@
##           developer     #308      +/-   ##
=============================================
+ Coverage      46.73%   47.00%   +0.27%     
=============================================
  Files            148      148              
  Lines          16225    16458     +233     
  Branches        2196     2219      +23     
=============================================
+ Hits            7582     7736     +154     
- Misses          7987     8052      +65     
- Partials         656      670      +14     
Files Coverage Δ
tests/FSharp.Stats.Tests/DistanceMetrics.fs 100.00% <100.00%> (ø)
src/FSharp.Stats/DistanceMetrics.fs 25.23% <43.52%> (-15.68%) :arrow_down:

... and 71 files with indirect coverage changes