title: Time series distance metric
body: <p>In order to clusterize a set of time series I'm looking for a smart distance metric. 
  I've tried some well known metric but no one fits to my case.</p>
  
  <p>ex: Let's assume that my cluster algorithm extracts this three centroids [s1, s2, s3]:
  <a href="https://i.stack.imgur.com/07OJY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/07OJY.png" alt="enter image description here"></a></p>
  
  <p>I want to put this new example [sx] in the most similar cluster:</p>
  
  <p><a href="https://i.stack.imgur.com/owugh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/owugh.png" alt="enter image description here"></a></p>
  
  <p>The most similar centroids is the second one, so I need to find a distance function d that gives me <code>d(sx, s2) &lt; d(sx, s1)</code> and <code>d(sx, s2) &lt; d(sx, s3)</code> </p>
  
  <p><strong>edit</strong></p>
  
  <p>Here the results with metrics [cosine, euclidean,  minkowski, dynamic type warping]
  <img src="https://i.stack.imgur.com/OR6so.png" alt="enter image description here">]<a href="https://i.stack.imgur.com/OR6so.png" rel="noreferrer">3</a></p>
  
  <p><strong>edit 2</strong></p>
  
  <p>User Pietro P suggested to apply the distances on the <strong>cumulated version of the time series</strong>
  The solution works, here the plots and the metrics:
  <a href="https://i.stack.imgur.com/ivhyt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ivhyt.png" alt="enter image description here"></a></p>