def G(w, Xs):
n = len(Xs)<EOL>P = projection_matrix(w)<EOL>Ys = [np.dot(P, X) for X in Xs]<EOL>A = calc_A(Ys)<EOL>A_hat = calc_A_hat(A, skew_matrix(w))<EOL>u = sum(np.dot(Y, Y) for Y in Ys) / n<EOL>v = np.dot(A_hat, sum(np.dot(Y, Y) * Y for Y in Ys)) / np.trace(np.dot(A_hat, A))<EOL>return sum((np.dot(Y, Y) - u - <NUM_LIT:2> * np.dot(Y, v)) ** <NUM_LIT:2> for Y in Ys)<EOL>
Calculate the G function given a cylinder direction w and a
    list of data points Xs to be fitted.