aboutsummaryrefslogtreecommitdiff
path: root/source/clusters.py
diff options
context:
space:
mode:
Diffstat (limited to 'source/clusters.py')
-rwxr-xr-xsource/clusters.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/clusters.py b/source/clusters.py
index 02766bdf..e53fac9b 100755
--- a/source/clusters.py
+++ b/source/clusters.py
@@ -1,6 +1,7 @@
#! /usr/bin/env python
#-*- coding: utf-8 -*-
+import math
import random
from math import sqrt
@@ -51,6 +52,12 @@ def tanimoto(v1, v2):
shr += 1 # in both
return 1.0 - (float(shr) / (c1 + c2 - shr))
+def euclidian(v1, v2):
+ d = 0.0
+ for i in range(len(v1)):
+ d += (v1[i] - v2[i])**2
+ return math.sqrt(d)
+
def kcluster(rows,distance=pearson,k=4):
# Determine the minimum and maximum values for each point
ranges=[(min([row[i] for row in rows]),max([row[i] for row in rows]))
bgstack15