#!/usr/bin/env python
# -*- coding: utf-8 -*-
X = (2, 3, 6)
Y = (3, 4)
M = ((0.10, 0.16, 0.06),
(0.15, 0.23, 0.30))
#X = (0.1, 0.3, 0.6)
#Y = (2, 5)
#M = ((0.05, 0.25, 0.30),
#(0.20, 0.14, 0.06))
Mx = sum(sum([x*p for x,p in zip(X,line)]) for line in M)
My = sum(y*sum(line) for y,line in zip(Y,M))
Dx = sum(sum([((x-Mx)**2)*p for x,p in zip(X,line)]) for line in M)
Dy = sum(((y-My)**2)*sum(line) for y,line in zip(Y,M))
Muxy = 0
for j, x in enumerate(X):
for i, y in enumerate(Y):
Muxy += (x-Mx)*(y-My)*M[i][j]
print "Mx:", Mx
print "My:", My
print "Dx:", Dx
print "Dy:", Dy
print "Muxy:", Muxy