Skip to content

Commit

Permalink
Added time-series averaging to example
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephBond committed Oct 11, 2023
1 parent 481cb13 commit ddf3d03
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
15 changes: 15 additions & 0 deletions fluid/example/slicing/dtw/average-series.fld
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let d x y = (x - y) * (x - y);
let avg x y = (x + y) / 2;
let avgSeq seq1 seq2 fn pairs =
let worker seq1 seq2 fn (i, j) =
let x = nth (i - 1) seq1;
y = nth (j - 1) seq2
in
fn x y
in map (worker seq1 seq2 fn) pairs;

let seq1 = [3,1,2,2,1];
seq2 = [2,0,0,3,3,1,0];
window = 2;
(costs, matched) = computeDTW seq1 seq2 d window
in avgSeq seq1 seq2 avg matched
2 changes: 1 addition & 1 deletion fluid/example/slicing/dtw/compute-dtw.fld
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ let d x y = (x - y) * (x - y);
let seq1 = [3,1,2,2,1];
seq2 = [2,0,0,3,3,1,0];
window = 2
in computeDTW seq1 seq2 d window
in computeDTW seq1 seq2 d window
4 changes: 4 additions & 0 deletions test/Spec/Specs.purs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ misc_cases =
\ Infty, Infty, FNum 6, FNum 10, FNum 5, FNum 5, FNum 6, Infty,\n\
\ Infty, Infty, Infty, FNum 7, FNum 9, FNum 9, FNum 5, FNum 6, ((1, 1) : ((2, 2) : ((2, 3) : ((3, 4) : ((4, 5) : ((5, 6) : ((5, 7) : []))))))))"
}
, { file: "slicing/dtw/average-series"
, fwd_expect:
"(2.5 : (0.5 : (0.5 : (2.5 : (2.5 : (1.0 : (0.5 : [])))))))"
}
]

desugar_cases :: Array TestSpec
Expand Down

0 comments on commit ddf3d03

Please sign in to comment.