Created
July 31, 2024 07:36
-
-
Save abhishek-ghose/04750e46ebaf27117ea6745019918276 to your computer and use it in GitHub Desktop.
Revisions
-
abhishek-ghose created this gist
Jul 31, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ import numpy as np def kendall_w(scores): """ :param scores: rows correspond to category levels, e.g., for QS this would be unc. sampling, CAL etc, and the columns correspond to the scores. :return: """ if scores.ndim!=2: raise 'scores matrix must be 2-dimensional' m = scores.shape[0] # raters/levels n = scores.shape[1] # items rated score_ranks = np.argsort(scores, axis=1) denom = m**2*(n**3-n) rating_sums = np.sum(score_ranks, axis=0) S = n*np.var(rating_sums) return 12*S/denom