From 2126631c7e8e80de19200d29435a74a8d696e8d3 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Wed, 24 Jun 2020 10:47:56 +0200 Subject: [PATCH] docstring and example update --- examples/mixed_bag.jl | 16 ++++++++++++---- src/MatrixProfile.jl | 4 ++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/mixed_bag.jl b/examples/mixed_bag.jl index bd230ed..bfa1222 100644 --- a/examples/mixed_bag.jl +++ b/examples/mixed_bag.jl @@ -43,17 +43,25 @@ plot(profile, mot, legend=false) plot(mot) using DynamicAxisWarping -using MatrixProfile: znorm -dist = DTWDistance(DTW(3)) +dist = DTW(3) normalizer = Val(ZNormalizer) profile2 = matrix_profile(T, 50, dist, normalizer=normalizer) -mot2 = motifs(profile2, 4, r=3, th=200, dist=(x,y)->dist(znorm(x),znorm(y))) + +using Distances +struct ZWrapper{D} <: Distances.Metric + dist::D +end +function Distances.evaluate(d::ZWrapper, x, y) + evaluate(d.dist, znorm(x), znorm(y)) +end +(d::ZWrapper)(x,y) = evaluate(d,x,y) + +mot2 = motifs(profile2, 4, r=3, th=200, dist=ZWrapper(dist)) plot(profile2, mot2, legend=false) plot(mot2) - snips = snippets(T, 4, 100, dist) plot(snips) diff --git a/src/MatrixProfile.jl b/src/MatrixProfile.jl index 3580274..2bb8aba 100644 --- a/src/MatrixProfile.jl +++ b/src/MatrixProfile.jl @@ -53,7 +53,11 @@ function matrix_profile(T::AbstractVector{<:Number}, m::Int; showprogress=true) Profile(T, P, I, m, nothing) end +""" + profile = matrix_profile(A, T, m, dist=ZEuclidean(); showprogress=true) +Mutual matrix profile between `A` and `T`. +""" function matrix_profile(A::AbstractVector{<:Number}, T::AbstractVector{<:Number}, m::Int; showprogress=true) n = length(A) l = n-m+1