Search code examples
algorithmranking

Calculate comparative rank of things compared two at a time


How to calculate the weights of 10 things that express a person's relative preference when the input data is as follows:

The list of 10 things are presented in random pairs (ignoring order, so A vs B might be shown, or B vs A, but not both; and not an item with itself);

A is better than B
D is better than F
H is better than B
C is better than J

etc.

Is there a way to rank or weight the 10 items from data like this? And is there a way to shorten the sequence from 10! / (2! (10 - 2)!) =45 questions.


Solution

  • You're making a dangerous psychological assumption here: you assume that the "better than" relation is transitive, so that from

    A > B
    B > C
    

    directly follows that

    A > C
    

    That is, without loss of generality, not the case for humans preferences. So this puts your whole approach in a questionable light.

    However, if you can justify that assumption, yeah, this breaks down to a sorting problem. There's a truckload of sorting algorithms out there, that just rely on the existence of an ordering relation ">". Your weight is then just the position in the sorted list.

    Every real-world programming language out there probably has a library that contains at least one sorter algorithm; most languages also have a way of specifying which function to call to compare two elements, so this really boils down to calling that sorter function with the unsorted list and the function to call when comparing two things.

    If the assumption that the "better than" relation is transitive cannot be made, things get a lot more complex. Basically, you can build a directed graph and try to find paths through it, but that graph might not be cycle free, and there might be no definite possibility to assign any weights.

    There's decades of psychological method research on how to test such things; I'd recommend finding a university that offers psychology programmes and asking the people there.