I want to represent the columns of one 2d array as the sum of the subset of the columns of another matrix. What is the most efficient way ?.
Right now, what I does is,
for i in xrange(U.shape[1])
U[:,i] = X[:,np.random.choice(X.shape[1], 10)].sum(axis=1)/10.0;
Is there a faster and better non-loop method ?