function [orderedAlgorithms,orderedResults] = myMAR(actuals,predictions,algorithms) % AR = abs(actual - predicted) and MAR is the mean of all ARs % define a variable to keep the MAR results for each algorithm arResults = -1 * ones(size(algorithms,2),size(actuals,1)); % process each algorithm's results for i = 1:size(algorithms,2) arResults(i,:) = abs(actuals - predictions(:,i)); end % define win tie loss variables win = zeros(size(algorithms,2),1); tie = zeros(size(algorithms,2),1); loss = zeros(size(algorithms,2),1); % start calculating win tie loss values for i = 1:size(algorithms,2) for j = (i+1):size(algorithms,2) if i ~= j % if i and j are different for k = 1:size(mre1,1) eval(['[P,H] = RANKSUM(arResults(',num2str(i),',:),arResults(',num2str(j),',:));']); if H == 0 % if they are the same eval(['tie(',num2str(i),') = tie(',num2str(i),') +1;']); eval(['tie(',num2str(j),') = tie(',num2str(j),') +1;']); else % calculate mean values eval(['mari = mean(arResults(',num2str(i),',:));']); eval(['marj = mean(arResults(',num2str(j),',:));']); if mari < marj eval(['win(',num2str(i),') = win(',num2str(i),') +1;']); eval(['loss(',num2str(j),') = loss(',num2str(j),') +1;']); else eval(['win(',num2str(j),') = win(',num2str(j),') +1;']); eval(['loss(',num2str(i),') = loss(',num2str(i),') +1;']); end end end end end end % and now write the loss values to the file fid=fopen('RUN_RESULTS.txt','a' ); for i = 1:size(algorithms,2) fprintf(fid, [num2str() ',']); end fprintf(fid, ['\n']); % append a new line at the end of the line % close file fclose(fid); end