Rewriting the above to compute for any number of bets would seem simplest--
function [stat,mxIdx] = bestbets(odds)
C = nanmean(odds,2);
[D,mxIdx] = max(odds,[],2);
E = 1/sum(1./D);
F = 1/sum(1./C);
G = C./F;
stat=zeros(size(D));
indx=1:length(D);
for i=1:length(D)
stat(i,:) = 1/sum([1/D(i); 1./G(~(ix==i))])-1;
end
Above reproduces your check array values for the given dataset.
NB: Above presumes the input odds array has been cleaned up before being passed, the problem about generating a suitable file format is a different discussion than than the algorithm implementation.
The loop could be eliminated with accumarray but left so could more easily get the implementation.
The "trick" is in building the logical addressing vector ~(indx==i) to select the elements from the G array with the exception of the one element being computed.
PS: While the computer doesn't care, as a general best practice I'd suggest using descriptive names for variables rather than just C, D, etc. It'll be bound to help in the long run as you develop into using Matlab and other programming languages more. I'll give high marks for brevity; that is also in my (nsh :) ) opinion an objective as exceedingly long variable names tend to just add clutter more than clarify, but at least some sort of a mnemonic to relate to the purpose is important for legibility.
ERRATUM Corrected order of function line to get function keyword first...
Best Answer