Distance Computations
=====================

Dynamic Time Warping
--------------------

Features:

  * Naive and Derivative [Keogh01]_ DTW
  * Symmetric, Asymmetric, Quasi-Symmetric implementation with Slope Constraint Condition P=0 [Sakoe78]_
  * Sakoe-Chiba window condition [Sakoe78]_ option
  * Linear space-complexity implementation option
  
.. autoclass:: mlpy.Dtw
   :members:

   .. versionadded:: 2.0.7

Extended example (requires matplotlib module):

.. code-block:: python
   
   >>> import numpy as np
   >>> import matplotlib.pyplot as plt
   >>> import mlpy
   >>> x = np.array([1,1,2,2,3,3,4,4,4,4,3,3,2,2,1,1])
   >>> y = np.array([1,1,1,1,1,1,1,1,1,1,2,2,3,3,4,3,2,2,1,2,3,4])
   >>> plt.figure(1)
   >>> plt.subplot(211)
   >>> plt.plot(x)
   >>> plt.subplot(212)
   >>> plt.plot(y)
   >>> plt.show()

.. image:: images/time_series.png

.. code-block:: python

   >>> mydtw = mlpy.Dtw()
   >>> d = mydtw.compute(x, y)
   >>> plt.figure(2)
   >>> plt.imshow(mydtw.cost.T, interpolation='nearest', origin='lower')
   >>> plt.plot(mydtw.px, mydtw.py, 'r')
   >>> plt.show()

.. image:: images/dtw.png


Minkowski Distance
------------------

.. autoclass:: mlpy.Minkowski
   :members:

   .. versionadded:: 2.0.8





.. [Senin08] Pavel Senin. Dynamic Time Warping Algorithm Review
.. [Keogh01] Eamonn J. Keogh and Michael J. Pazzani. Derivative Dynamic Time Warping. First SIAM International Conference on Data Mining (SDM 2001), 2001.
.. [Sakoe78] Hiroaki Sakoe and Seibi Chiba. Dynamic Programming Algorithm Optimization for Spoken Word Recognition. IEEE Transactions on Acoustics, Speech, and Signal Processing. Volume 26, 1978.