weightedmean.m (404B)
1 function means=weightedmean(X,weights); 2 3 % weightedmean.m 11/19/99 4 % 5 % function means=weightedmean(X,weights); 6 % 7 % Function to compute the weighted mean of the columns of a matrix. 8 % X = The matrix 9 % weights = The weights (need not sum to 1; we'll normalize). 10 11 w=weights/sum(weights); 12 Xw=mult(X,w); % Multiply each column by w 13 means=sum(Xw); % And then add up...