% mu = weighted_mean(x,w)
% x is n x d, w is n x 1
function mu = weighted_mean(x,w)

%[n,d] = size(x);

z = sum(w);
x((isnan(x)|isinf(x)) & (w(:)==0)) = 0;
mu = sum(bsxfun(@times,x,w(:)),1)/z;
kristinbranson
github-repos/MATLAB/kristinbranson-JAABA/JAABA-5d778a23e3e7cf272df9a89a72b1b66d94f535d7/misc/weighted_mean.m
JAABA
github-repos/MATLAB/kristinbranson-JAABA
5d778a23e3e7cf272df9a89a72b1b66d94f535d7