As the documentation in Details and Options indicating,any custom DistanceFunction
is not allowed:
WarpingCorrespondence accepts a DistanceFunction->d
option with settings
We can know Total[Abs[u-v]]/Total[Abs[u+v]]
is equivalent to the BrayCurtisDistance
totally as its documentation,but regard this example:
WarpingCorrespondence[s1, s2,
DistanceFunction -> BrayCurtisDistance]
(* {{1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 9, 10, 10, 10, 11, 12, 12,
12, 12, 13, 13, 13}, {1, 1, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17}} *)
WarpingCorrespondence[s1, s2,
DistanceFunction ->
Function[{u, v}, Total[Abs[u - v]]/Total[Abs[u + v]]]]
(*Get nothing*)
When we use GeneralUtilities`PrintDefinitions
to see the interior code,we can find all trick in the Signal`TimeWarpingDump`iTimeWarping
.A important code constrain this behavior
If[
!MatchQ[distance,
Alternatives[Automatic,
BrayCurtisDistance, CanberraDistance, EuclideanDistance, SquaredEuclideanDistance,
NormalizedSquaredEuclideanDistance, BinaryDistance, ManhattanDistance, ChessboardDistance,
CosineDistance, CorrelationDistance, MatchingDissimilarity, "DerivativeDistance"
]
],
Message[Signal`TimeWarpingDump`h::invdist, distance];
Return[$Failed]
]
We can consider get rid of this limitation to implement our custom distance function.
A workaround
Since it just accept a specified list,we can make use of this feature to implement our custom distance function like this
Block[{BrayCurtisDistance},BrayCurtisDistance[x1_, x2_] := (x1 - x2)^2;
WarpingCorrespondence[s1, s2, DistanceFunction -> BrayCurtisDistance]]
{{1,2,3,4,5,6,7,8,8,8,9,10,10,10,11,12,12,12,12,13,13,13},{1,1,1,1,1,2,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}}
Of course,you can use other valid function in that list,but I have not test any side effect.use it carefully,please.
non-Euclidean
distance function as its Details and Options.I don't sure your have seem it. $\endgroup$