Code covered by the BSD License  

Highlights from
Rankings

5.0
5.0 | 1 rating Rate this file 21 Downloads (last 30 days) File Size: 10.9 KB File ID: #19496 Version: 1.1

Rankings

by

 

08 Apr 2008 (Updated )

Calculate Rankings with five different methodologies

| Watch this File

File Information
Description

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.

Acknowledgements

Freqtable inspired this file.

MATLAB release MATLAB 7 (R14)
MATLAB Search Path
/
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
15 Aug 2015 Liber Eleutherios

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.

Comment only
13 Aug 2015 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.

Comment only
13 Aug 2015 Liber Eleutherios

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!

Comment only
12 Aug 2015 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...

Comment only
31 Jan 2012 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.

Comment only
14 Feb 2011 Jaroslaw Tuszynski  
23 Apr 2010 Liber Eleutherios

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"

Comment only
Updates
09 Apr 2008

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

10 Apr 2008

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

12 Jan 2015 1.1

minor edits

Contact us