title: Compare two user defined curves and score their similarity
body: <p>I have a set of 2 curves (each with a few hundreds to a couple thousands datapoints) that I want to compare and get some similarity "score". Actually, I have >100 of those sets to compare... I am familiar with R (or at least bioconductor) and would like to use it.</p>
  
  <p>I tried the <code>ccf()</code> function but I'm not too happy about it.</p>
  
  <p>For example, if I compare c1 to the following curves:</p>
  
  <pre><code>c1 &lt;- c(0, 0.8, 0.9, 0.9, 0.5, 0.1, 0.5)
  
  c1b &lt;- c(0, 0.8, 0.9, 0.9, 0.5, 0.1, 0.5) # perfect match! ideally score of 1
  
  c1c &lt;- c(1, 0.2, 0.1, 0.1, 0.5, 0.9, 0.5) # total opposite, ideally score of -1? (what would 0 be though?)
  
  c2 &lt;- c(0, 0.9, 0.9, 0.9, 0, 0.3, 0.3, 0.9) #pretty good, score of ???
  </code></pre>
  
  <p>Note that the vectors don't have the same size and it needs to be normalized, somehow... Any idea?
  If you look at those 2 lines, they are fairly similar and I think that in a first step, measuring the area under the 2 curves and subtracting would do. I look at the post "Shaded area under 2 curves in R" but that is not quite what I need.</p>
  
  <p>A second issue (optional) is that for lines that have the same profile but different amplitude, I would like to score those as very similar even though the area under them would be big:</p>
  
  <pre><code>c1 &lt;- c(0, 0.8, 0.9, 0.9, 0.5, 0.1, 0.5)
  
  c4 &lt;- c(0, 0.6, 0.7, 0.7, 0.3, 0.1, 0.3) # very good, score of ??
  </code></pre>
  
  <p>I hope that a biologist pretending to formulate problem to programmer is OK...</p>
  
  <p>I'd be happy to provide some real life examples if needed.</p>
  
  <p>Thanks in advance!</p>