File Exchange

image thumbnail

Rankings

version 1.1 (10.9 KB) by

Calculate Rankings with five different methodologies

4 Downloads

Updated

View License

There exist many different ranking methodologies.
For more details, check here: http://en.wikipedia.org/wiki/Ranking .
*****************************************

The archive contains the following files:

Rankings.m
FractionalRankings.m
FractionalRankings2.m
DenseRankings.m
StandardCompetitionRankings.m
ModifiedCompetitionRankings.m
OrdinalRankings.m
OrdinalRankings2.m

*****************************************

The principal function is Rankings.m which can be used to calculate five different kinds of rankings (in ascending order):

FRACTIONAL RANKINGS (1 2.5 2.5 4)
DENSE RANKINGS (1 2 2 3)
STANDARD COMPETITION RANKINGS (1 2 2 4)
MODIFIED COMPETITION RANKINGS (1 3 3 4)
ORDINAL RANKINGS (1 2 3 4) OR (1 3 2 4)

If you need to use the rankings for statistical purposes, the most useful methodology is probably the Fractional Ranking because it is such that the sum of N ranks is equal to sum([1:N]), so that the average rank of N items is always the same.

Due to its special statistical properties, the default method is the Fractional Ranking.

*****************************************

The file FractionalRankings2.m contains an alternative function for the computation of Fractional Rankings but it's extremely slow and inefficient and, actually, it is not supposed to be used but for general consultation.

I chose to keep it because it is the most intuitive code, though it cannot be implemented efficiently in Matlab.

The file OrdinalRankings2 contains an alternative function for the computation of Ordinal Rankings that seems to be slightly less efficient than the one contained in the file OrdinalRankings.m, and also much more complicated and less readable.

I chose to leave it in the archive for general consultation.

*****************************************

Please let me know if there are bugs or if you find better solutions. Thank you.

Comments and Ratings (7)

Hi Daniele,

I'm not entirely sure I understand what you are trying to do. I thought you were trying to write your own _mex function.

However if you are trying to automatically convert the Matlab function into a _mex function I'm afraid the performance will not improve much (or at all).

In order to avoid the error you reported, you actually have to re-write the function, redefine the variable FreqTab and probably introduce many other changes. I doubt it will be worth the effort.

Please contact me by email to discuss this further.

daniele

Thanks for the reply.
I mean when i try to create a _mex function the following error appears:
"??? Undefined function or variable 'FreqTab'. The first assignment to a local variable determines its class."
The same error also appear on N2.

Hi Daniele, thank you for your comment.

What error do you get on FreqTab? I have just tried

x = ceil(10000 * rand(10000000, 1));
tic
y = StandardCompetitionRankings(x);
toc

and it seems to be working alright (in this instance "Elapsed time is 5.601218 seconds").

I am pretty sure the performance can be greatly improved if you write a mex function - give it try!

daniele

Thanks Liber for the great job.
Is it possible to speed up the codes (in my case i'm interested in StandardCompetitionRankings) via _mex function? If i use the unique function the computation time is less than half but i need the logic you use in the StandardCompetitionRankings.
The code generation readiness give me an error on FreqTab...

Daniel

Daniel (view profile)

You might like my tiedrank_(X,dim) function: http://www.mathworks.com/matlabcentral/fileexchange/34560-tiedrankxdim
The code is fully vectorised and runs pretty fast.

Apparently, Matlab function "tiedrank" does the same as my FractionalRankings.

This function ("tiedrank") is not described in the Help Files, but you can visualize its description on the Command Window:

help tiedrank

or by directly opening file "tiedrank.m"

Updates

1.1

minor edits

I've changed the function OrdinalRanking: hope it is more clear, intuitive and efficient.

I've tried to fix some errors.
Two more general examples are added to the file Rankings.m

MATLAB Release
MATLAB 7 (R14)
Acknowledgements

Inspired by: FREQTABLE

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video