diff python/indicators.py @ 316:c5518a35df5f

merged
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 12 Apr 2013 15:22:00 -0400
parents 43e62b9cb652
children a5e40bd04cf4
line wrap: on
line diff
--- a/python/indicators.py	Fri Apr 12 13:16:38 2013 -0400
+++ b/python/indicators.py	Fri Apr 12 15:22:00 2013 -0400
@@ -93,6 +93,31 @@
         plot([x/xfactor for x in time], [self.values[i] for i in time], options+marker, **kwargs)
         if self.maxValue:
             ylim(ymax = self.maxValue)
+	
+    def valueSorted(self):
+	''' return the values after sort the keys in the indicator
+    This should probably not be used: to delete''' 
+        values=[]
+        keys = self.values.keys()
+        keys.sort()
+        for key in keys:
+            values.append(self.values[key]) 
+        return values
+
+    @staticmethod
+    def getDLCSS(indic1, indic2, threshold, delta = float('inf') , method ='min' ):
+	''' compute the distance between two indicators using LCSS
+	two common methods are used: min or mean of the indicators length'''
+        l1 = indic1.valueSorted
+        l2 = indic2.valueSorted
+        DLCSS = None
+        if method == 'min':
+            DLCSS = 1- (LCSS(l1,l2, threshold, delta, distance))/min(len(l1),len(l2))
+        if method == 'mean':
+            average = len(l1)+len(l2)/2
+            DLCSS = 1- ((LCSS(l1,l2, threshold, delta, distance))/average)
+        return DLCSS
+		
 
 def computeDLCSS(indicator1, indicator2, threshold, delta = float('inf'), method= 'min'):
     ''' compute the distance between two indicators using LCSS