MCPcopy Index your code
hub / github.com/clips/pattern / mean

Function mean

pattern/vector/__init__.py:1393–1400  ·  view source on GitHub ↗

Returns the arithmetic mean of the values in the given iterable or iterator.

(iterable, length=None)

Source from the content-addressed store, hash-verified

1391# The k_means() and hierarchical() functions work with Vector objects or dictionaries.
1392
1393def mean(iterable, length=None):
1394 """ Returns the arithmetic mean of the values in the given iterable or iterator.
1395 """
1396 if length is None:
1397 if not hasattr(iterable, "__len__"):
1398 iterable = list(iterable)
1399 length = len(iterable)
1400 return sum(iterable) / float(length or 1)
1401
1402def centroid(vectors=[], features=[]):
1403 """ Returns the center of the given list of vectors.

Callers 1

centroidFunction · 0.70

Calls 2

lenFunction · 0.85
sumFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…