# \[ANN\] DynamicAxisWarping.jl

**URL:** <https://discourse.julialang.org/t/ann-dynamicaxiswarping-jl/40146>\
**Category:** Package Announcements\
**Tags:** package, time-series, dsp\
**Created:** [May 25, 2020, 6:03pm UTC](https://discourse.julialang.org/t/ann-dynamicaxiswarping-jl/40146 "2020-05-25T18:03:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [May 25, 2020, 6:03pm UTC](https://discourse.julialang.org/t/ann-dynamicaxiswarping-jl/40146/1 "2020-05-25T18:03:06Z")

</div>

I would like to announce [DynamicAxisWarping.jl](https://github.com/baggepinnen/DynamicAxisWarping.jl) which provides a bunch of algorithms related to Dynamic Time Warping, such as

- DTW
- FastDTW
- SoftDTW (differentiable)
- Optimized nearest neighbor search
- Barycenter averaging
- DTW Clustering
- Matrix profile using DTW distance
- Implements the Distances.jl interface

![doppler](https://raw.githubusercontent.com/baggepinnen/DynamicAxisWarping.jl/master/examples/doppler.svg)

Being a Julia package, we support arbitrary metrics and arbitrary “spaces”, i.e., as long as you are passing a vector or higher dimensional array of something that your distance can operate on, you’re good to go. Time is always considered to be the last dimension. [Here’s an example](https://nbviewer.jupyter.org/github/baggepinnen/julia_examples/blob/master/frequency_warping.ipynb) using DTW on spectrograms.

Out of the UCR suite of optimizations, most are implemented

- Endpoint lower bound pruning
- Envelope lower bound pruning
- DTW early termination
- Online normalization (also works for 2D input)
- Sorting of query series

Further, all algorithms operate on arbitrary precision numbers. If you pass them `Float32` instead of `Float64`, they can become up to twice as fast.

Thanks to @ericphanson, we have some benchmarks indicating we’re quite a bit faster than the python package `fastdtw`.

Early parts of this package came from a fork of the abandoned TimeWarp.jl, which in turn built upon the also abandoned DynamicTimeWarping.jl

Happy distance measuring! 😃

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [May 25, 2020, 6:21pm UTC](https://discourse.julialang.org/t/ann-dynamicaxiswarping-jl/40146/2 "2020-05-25T18:21:32Z")

</div>

> Optimized nearest neighbor search

Can you give some info on what this means? After having a look at the wiki page for Dynamic time warping, I don’t immediately see what this could mean.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [May 25, 2020, 6:23pm UTC](https://discourse.julialang.org/t/ann-dynamicaxiswarping-jl/40146/3 "2020-05-25T18:23:18Z")

</div>

It essentially means that your searching through one long time series for a much shorter pattern. This is a common operation when you’re doing “detection”, and it can be optimized quite heavily.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [June 11, 2020, 7:07am UTC](https://discourse.julialang.org/t/ann-dynamicaxiswarping-jl/40146/4 "2020-06-11T07:07:58Z")

</div>

Some updates:

In the [latest version](https://github.com/baggepinnen/DynamicAxisWarping.jl/releases/tag/v0.2.3), we now have

- [An implementation](https://github.com/baggepinnen/DynamicAxisWarping.jl#generalized-dtw) of [_A General Optimization Framework for Dynamic Time Warping_](https://arxiv.org/abs/1905.12893), which provides ways of regularizing the warping path. [Here’s an example](https://github.com/baggepinnen/DynamicAxisWarping.jl/blob/master/examples/gdtw.jl). Big thanks to @ericphanson for contributing this!
- [An implementation](https://github.com/baggepinnen/DynamicAxisWarping.jl#differentiable-soft-dtw) of [_Soft-DTW_](https://arxiv.org/pdf/1703.01541.pdf) that is differentiable and can be used to find barycenters etc. [Here’s an example](https://github.com/baggepinnen/DynamicAxisWarping.jl/blob/master/examples/softDTW.jl).

---

<div class="post-metadata">

**Author:** ![Marc.Cox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marc.cox/32/7514_2.png) [@Marc.Cox](https://discourse.julialang.org/u/Marc.Cox)\
**Post date:** [August 26, 2020, 2:41am UTC](https://discourse.julialang.org/t/ann-dynamicaxiswarping-jl/40146/5 "2020-08-26T02:41:11Z")

</div>

Thank You , Dynamic Time Warping looks great I can’t wait to try it out.

Very interested in running **[https://github.com/baggepinnen/DynamicAxisWarping.jl/blob/master/examples/frequency\_warping2.jl](https://github.com/baggepinnen/DynamicAxisWarping.jl/blob/master/examples/frequency_warping2.jl)** but I seem to have the wrong Julia version 1.04 per precompile errors below , ideally Julia LTS v1.04 or v1.05 could be made to work for compatiblity with other Julia packages, but if that’s not possible which versions greater than _x.y.z_ of Julia work please ?

```julia
julia> using DynamicAxisWarping
[Info: Precompiling DynamicAxisWarping [aaaaaaaa-4a10-5553-b683-e707b00e83ce]
ERROR: LoadError: LoadError: syntax: invalid function name "DTWDistance{M <: DTWMethod, D <: SemiMetric} <: SemiMetric"
Stacktrace:
 [1] include at ./boot.jl:317 [inlined]
	.
	.
 [10] eval at ./boot.jl:319 [inlined]
 [11] eval(::Expr) at ./client.jl:393
 [12] top-level scope at ./none:3
in expression starting at /home/marc/.julia/packages/DynamicAxisWarping/xuab5/src/distance_interface.jl:18
in expression starting at /home/marc/.julia/packages/DynamicAxisWarping/xuab5/src/DynamicAxisWarping.jl:40
ERROR: Failed to precompile DynamicAxisWarping [aaaaaaaa-4a10-5553-b683-e707b00e83ce]

```

Also thought I should mention this “You can always suggest to package authors that they install `CompatHelper.jl`.” per this post [Can someone help me on how to resolve package conflicts with dev'ed packages? - #4 by dilumaluthge](https://discourse.julialang.org/t/can-someone-help-me-on-how-to-resolve-package-conflicts-with-deved-packages/39351/4)

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [August 26, 2020, 4:05am UTC](https://discourse.julialang.org/t/ann-dynamicaxiswarping-jl/40146/6 "2020-08-26T04:05:04Z")

</div>

Oh, it seems that the compat declaration for Julia is wrong 😕 I have really only tested the package on the latest version of Julia, which was 1.4 at the time. I used to try to maintain compat with older Julia versions, but noticed that it took a lot of my bandwidth for little gain and decided to not pursue that anymore.

If you’re interested in distances between spectra, you may also be interested in the examples over at

- [Time-Frequency distances · SpectralDistances](https://baggepinnen.github.io/SpectralDistances.jl/latest/time/)
- [Examples · SpectralDistances](https://baggepinnen.github.io/SpectralDistances.jl/latest/examples/#Computing-a-spectrogram-distance-profile-1)
