This simple example shows how to write an IMP.statistics.Metric in python.
14 """Define a metric on a list of floating point numbers based on their difference"""
16 def __init__(self, nums):
17 """Store the list of numbers to measure distances between"""
18 IMP.statistics.Metric.__init__(self,
"MyMetric%1%")
22 """Return the magnitude of the distance between the ith and jth number"""
23 return math.fabs(self._nums[i] - self._nums[j])
25 def get_number_of_items(self):
26 return len(self._nums)
29 mm = MyMetric([random.uniform(0, 1)
for i
in range(0, 15)])
32 print(cc.get_number_of_clusters())