• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Apr 9th, 2020 153 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. ###########
2.
3. def moyenne(l, cent):
4.     n = len(l)
5.     if n == 0:return float("inf")
6.     s = 0
7.     for i in range(n):
8.         s += distance(cent, l[i])
9.     return s/n
10.
11.
12. def centroide(l):
13.     if len(l) == 0:return [0,0]
14.     xs = 0
15.     ys = 0
16.     for p in l:
17.         xs += p[0]
18.         ys += p[1]
19.
20.     return [xs/len(l),ys/len(l)]
21.
22.
23. def distance(p1,p2):
24.     i = p1[0] - p2[0]
25.     j = p1[1] - p2[1]
26.     return sqrt(i*i + j*j)
27.
28. def metrique(z):
29.     somme = 0
30.     for i in range(len(z)):
31.         formule = []
32.         centI = centroide(z[i])
33.         sigmaI = moyenne(z[i], centI)
34.         for j in range(len(z)):
35.             if (i==j):continue
36.             centJ = centroide(z[j])
37.             sigmaJ = moyenne(z[j], centJ)
38.             d = distance(centI,centJ)
39.             # division par 0
40.             if  d > 1e-8:
41.                 formule.append((sigmaI+sigmaJ)/d)
42.             else:
43.                 return float("inf")
44.         if formule:
45.             somme += max(formule)
46.
47.     return somme/7
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top