``````def CalcCentre(data):
centre = array([0,0,0])
count = 0
for p in data:
count += 1
centre = dot(1./count, centre)
return centre
``````

pretty useless until you give more codes to support that. sorry ..

Code use Numpy and it use function add() and dot().
To see what these numpy function dos,look into numpy doc here is add()
To test function so it work i guessed for a nested list as input data.

``````from numpy import *

def CalcCentre(data):
centre = array([0,0,0])
count = 0
for p in data:
count += 1
centre = dot(1./count, centre)
return centre

print CalcCentre(array([[1,2,3], [4,5,6]]))
#--> [ 2.5  3.5  4.5]
``````
commented: well spotted +13

So the function calculates the barycentre of a set of points in a multidimensional space.

``````import cv
from math import floor, sqrt, ceil
from numpy import array, dot, subtract, add, linalg as lin

def CalcCentre(data):
centre = array([0,0,0])
count = 0
n = 0
#data = list(data)
for p in data[n:n+3]:
count += 1
centre = dot(1./count, centre)
return centre
n += 1
f = open(filename)
result = []
for l in f:
sp = l.split()
t = tuple(map(float, sp[1:4]))
result.append(t)
return result

def main (data):

j = 0
for  i in len (data):
while j != 3:
centre = CalcCentre(data)
j += 1
print centre

if __name__ == '__main__':