For a few days I was wondering on how to efficiently implement weighted majority voting of m experts in matlab. Here is an example of what I want. Suppose we have 3 experts
w=[7 2 6];
votes = ['A' 'B' 'B'
'C' 'A' 'A'
'D' 'B' 'A'
'A' 'A' 'C'];
options = ['A', 'B', 'C', 'D']';
%'//Make a cube of the options that is number of options by m by n
OPTIONS = repmat(options, [1, size(w, 2), size(votes, 1)]);
%//Compare the votes (streched to make surface) against a uniforma surface of each option
B = bsxfun(@eq, permute(votes, [3 2 1]) ,OPTIONS);
%//Find a weighted sum
W = squeeze(sum(bsxfun(@times, repmat(w, size(options, 1), 1), B), 2))'
%'//Find the options with the highest weighted sum
[xx, i] = max(W, [], 2);
options(i)
result:
B
A
D
A