Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## prea.util
Class Distance

    java.lang.Object
      prea.util.Distance

    public class Distance

extends java.lang.Object

This is a class implementing various distance measures of two vectors.

Since:
  2012. 4. 20
Version:
  1.1
Author:
  Mingxuan Sun

Constructor Summary
`Distance()`

Method Summary
`private static void` | `changePermutationIndex(int[] uItemID, int[] vItemID)` Given two permutation, re-index the id to the set {1,2,.., n}, where n is the total items of the two permutations.
`static void` | `computeAverageRank(double[] score, double[] prb)` Return the average rank of each score with/without ties prb=(lowrank+(tie-1)/2)/(k+1)
`static double` | `distanceKendall(int[] uItemID, double[] uScore, int[] vItemID, double[] vScore, int n)` Return the Kendall's Tau distance for two rankings.
`private static double` | `distanceKendallParsed(int[] uItemID, double[] uPrb, int[] vItemID, double[] vPrb, int n)` Return intermediate Kendall's Tau distance for two rankings parsed by prb
`static double` | `distanceNDCG(int[] uItemID, double[] relevance, int[] vItemID, double[] userScore)` Return NDCG score for a ranked list given the scores and relevance of items in the list.
`static double` | `distanceSpearman(int[] uItemID, double[] uScore, int[] vItemID, double[] vScore, int n)` Return Spearman distance for two rankings.
`static double` | `distanceSpearmanParsed(int[] uItemID, double[] uPrb, int[] vItemID, double[] vPrb, int n)` Return the Spearman distance for two rankings parsed by probability
`private static double` | `preferProbability(double avgRank_i, double avgRank_j)` Return the probability of the item i is preferred to the item j.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Distance

    public Distance()

Method Detail

### distanceNDCG

    public static double distanceNDCG(int[] uItemID,
                                      double[] relevance,
                                      int[] vItemID,
                                      double[] userScore)

  Return NDCG score for a ranked list given the scores and relevance of items in the list.

  Parameters:
    `uItemID` - array of userIds
    `relevance` - array of relevances for userIds
    `vItemID` - array of userIds may/maynot be in the same order as uItemID
    `userScore` - array of scores for userIds
  Returns:
    the NDCG score

### changePermutationIndex

    private static void changePermutationIndex(int[] uItemID,
                                               int[] vItemID)

  Given two permutation, re-index the id to the set {1,2,.., n}, where n is the total items of the two permutations. The original itemId will be re-ordered.

  Parameters:
    `uItemID` - array of itemID sorted increasingly
    `vItemID` - array of itemID sorted increasingly

### distanceKendallParsed

    private static double distanceKendallParsed(int[] uItemID,
                                                double[] uPrb,
                                                int[] vItemID,
                                                double[] vPrb,
                                                int n)

  Return intermediate Kendall's Tau distance for two rankings parsed by prb

  Parameters:
    `uItemID` - array of itemID sorted increasingly
    `uPrb` - array of probability for user u
    `vItemID` - array of itemID for user v sorted increasingly
    `vPrb` - array of probability for user v
    `n` - the number of total items
  Returns:
    the Kendall's Tau scores

### distanceKendall

    public static double distanceKendall(int[] uItemID,
                                         double[] uScore,
                                         int[] vItemID,
                                         double[] vScore,
                                         int n)

  Return the Kendall's Tau distance for two rankings.

  Parameters:
    `uItemID` - array of itemID
    `uScore` - array of score for user u
    `vItemID` - array of itemID for user v
    `vScore` - array of scores for user v
    `n` - the number of total items
  Returns:
    the Kendall's Tau distance

### distanceSpearmanParsed

    public static double distanceSpearmanParsed(int[] uItemID,
                                                double[] uPrb,
                                                int[] vItemID,
                                                double[] vPrb,
                                                int n)

  Return the Spearman distance for two rankings parsed by probability

  Parameters:
    `uItemID` - array of itemID sorted increasingly
    `uPrb` - array of probability for user u
    `vItemID` - array of itemID for user v sorted increasingly
    `vPrb` - array of probability for user v
    `n` - the number of total items
  Returns:
    the Spearman scores

### distanceSpearman

    public static double distanceSpearman(int[] uItemID,
                                          double[] uScore,
                                          int[] vItemID,
                                          double[] vScore,
                                          int n)

  Return Spearman distance for two rankings.

  Parameters:
    `uItemID` - array of itemID
    `uScore` - array of score for user u
    `vItemID` - array of itemID for user v
    `vScore` - array of scores for user v
    `n` - the number of total items
  Returns:
    the Spearman distance

### computeAverageRank

    public static void computeAverageRank(double[] score,
                                          double[] prb)

  Return the average rank of each score with/without ties prb=(lowrank+(tie-1)/2)/(k+1)

  Parameters:
    `score` - The array of scores
    `prb` - The array of average ranks will be filled.

### preferProbability

    private static double preferProbability(double avgRank_i,
                                            double avgRank_j)

  Return the probability of the item i is preferred to the item j.

  Parameters:
    `avgRank_i` - The average rank of item i
    `avgRank_j` - The average rank of item j
  Returns:
    the intermediate Kendall scores

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD