-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
minkowski distance #308
minkowski distance #308
Conversation
implement the minkowski distance of order p in several versions. add unit tests
Note that in a separate issue, one could try to tackle code duplications in the src and tests of distance metrics. |
src/FSharp.Stats/DistanceMetrics.fs
Outdated
let mutable acc = 0.0 | ||
|
||
for i in 0 .. (dim - 1) do | ||
let abs = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you didnt use abs (v1.[i] - v2.[i])
to determine the absolute difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other functions, such as cityblockNaN
used System.Math.Abs
So I wanted to keep it aligned, but I am more than happy to change it
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the addition! From the Wikipedia diagram I assume p could also be 0 < p <= 1
, but I did not went deeper into research. Is there a reason you constrain p to be an integer? Or did I miss something?
Regarding that p could also be 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 |
* replace System.Math functions * correct summaries * gernalize order p to be a float > 0 * extended unit tests
Pushed the feedback. The order |
Codecov Report
@@ 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
|
Please reference the issue(s) this PR is related to
Closes #182
Please list the changes introduced in this PR
DistanceMetrics.fs
for vectors, arrays and sequencesDescription
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]