Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Ranking-methods/Mathematica/ranking-methods.math
Normal file
19
Task/Ranking-methods/Mathematica/ranking-methods.math
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
data = Transpose@{{44, 42, 42, 41, 41, 41, 39}, {"Solomon", "Jason",
|
||||
"Errol", "Garry", "Bernard", "Barry", "Stephen"}};
|
||||
|
||||
rank[data_, type_] :=
|
||||
Module[{t = Transpose@{Sort@data, Range[Length@data, 1, -1]}},
|
||||
Switch[type,
|
||||
"standard", data/.Rule@@@First/@SplitBy[t, First],
|
||||
"modified", data/.Rule@@@Last/@SplitBy[t, First],
|
||||
"dense", data/.Thread[#->Range[Length@#]]&@SplitBy[t, First][[All, 1, 1]],
|
||||
"ordinal", Reverse@Ordering[data],
|
||||
"fractional", data/.Rule@@@(Mean[#]/.{a_Rational:>N[a]}&)/@ SplitBy[t, First]]]
|
||||
|
||||
fmtRankedData[data_, type_] :=
|
||||
Labeled[Grid[
|
||||
SortBy[ArrayFlatten@{{Transpose@{rank[data[[All, 1]], type]},
|
||||
data}}, First], Alignment->Left], type<>" ranking:", Top]
|
||||
|
||||
Grid@{fmtRankedData[data, #] & /@ {"standard", "modified", "dense",
|
||||
"ordinal", "fractional"}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue