Init

ClearAll["Global`*"] SetDirectory[NotebookDirectory[]];

Function

Country IOC Shorts (CHN) to short name (). ITTF use IOC code not ISO- Alpha 3.

countryCodeList= Import["input/countries(204)_olympics.csv"]; (* Remove the first title*) countryCodeList= Rest[countryCodeList]; Shortnamecountry= countryCodeList[[All, 2]]; IOC3country= countryCodeList[[All, 1]]; ToShortNameRule= Thread[IOC3country -> Shortnamecountry]; Take[ToShortNameRule, 10]

{AFG→ Afghanistan, ALB→ Albania, ALG→ Algeria, AND→ Andorra, ANG→ Angola, ANT→ Antigua and Barbuda, ARG→ Argentina, ARM→ Armenia, ARU→ Aruba, ASA→ American Samoa}

Data is a mix name (player name and country name)

nametoFlag[mixName_]:= Block{split}, split= StringExtract[mixName,-1]; (*CHN*) split= StringDelete[split, "("]; split= StringDelete[split, ")"]; (*CHN→ CHN*) split= split/. ToShortNameRule; Show[CountryData[split, "Flag"], ImageSize→ 22] 

getNameFromMix[mixName_]:= Block[{playerName}, (* remove the country short name*) playerName= StringExtract[mixName, 1 ;;-2]; (* add "space" in{MA,Long} and Join it ""*) playerName= StringRiffle[playerName] ]

Data is a match

getplayerNameFromMatch[match_]:= Block[{playerAName, playerXName, mixA, mixX}, mixA= match〚5〛;

Printed by Wolfram Mathematica Student Edition 2 ittf ranking.nb

mixX= match〚11〛; (* return playerA Name and playerX Name*) playerAName= getNameFromMix[mixA]; playerXName= getNameFromMix[mixX]; {playerAName, playerXName} ]

getplayerMixNameFromMatch[match_]:= Block[{mixA, mixX}, (* get player Name and Country(MIX) *) mixA= match〚5〛; mixX= match〚11〛; (* return mixA and mixX*) {mixA, mixX} ]

matchPoint[match_]:= Block[{winnerID, looserID, playerIDA, playerIDX, round, point, eventcoeff, eventName, scorecoeff, scoreA, scoreX, deltascore, tourName, tourcoeff}, tourName= match[[2]]; tourcoeff= Which[ StringContainsQ[tourName, ""], 9, StringContainsQ[tourName, "World Championships"], 7, StringContainsQ[tourName, "Men's World Cup"], 5,

StringContainsQ[tourName, "World Tour"], 4, StringContainsQ[tourName, "Asian Cup"], 3, StringContainsQ[tourName, "European"], 2, StringContainsQ[tourName, "ITTF Asian Championships"], 3.5, StringContainsQ[tourName, "ITTF Europe Cup"], 3,

StringContainsQ[tourName, "Challenge"], 1.5, StringContainsQ[tourName, "Oceania Cup"], 1, StringContainsQ[tourName, "Panam Cup"], 1, StringContainsQ[tourName, "Africa Cup"], 1,

(* Else*) True, 0.8 ]; winnerID= match[[20]]; playerIDA= match[[3]]; playerIDX= match[[9]]; If[winnerID⩵ playerIDA, looserID= playerIDX, looserID= playerIDA]; scoreA= match[[18]]; scoreX= match[[19]]; deltascore= Abs[scoreA- scoreX]; scorecoeff= Which[ deltascore⩵ 4, 1.5, deltascore⩵ 3, 1.332, deltascore⩵ 2, 1.166, deltascore⩵ 1, 1 ];

eventName= match[[15]]; round= match[[17]]; point= Which[

Printed by Wolfram Mathematica Student Edition ittf ranking.nb 3

(* "Men's Singles(Pre. Rounds)"*) eventName⩵ "Men's Singles(Pre. Rounds)", 2, (* "Men's Singles"*) eventName⩵ "Men's Singles" && round⩵ 128, 7, eventName⩵ "Men's Singles" && round⩵ 64, 10, eventName⩵ "Men's Singles" && round⩵ 32, 13, eventName⩵ "Men's Singles" && round⩵ 16, 17, eventName⩵ "Men's Singles" && round⩵ 8, 21, eventName⩵ "Men's Singles" && round⩵ 4, 24, eventName⩵ "Men's Singles" && round⩵ 2, 25, (* Else*) True, 1 ]; {winnerID, point* tourcoeff* scorecoeff} ]

Data is a tournament (list of match)

takeSingle[data_]:= Block{}, Select[data, #[[-1]]⩵1&] (* Select only The last columnKind equal to 1Single*) 

takeDouble[data_]:= Block{}, Select[data, #[[-1]]⩵2&] (* Select only The last columnKind equal to 2Double*) 

takeYear[data_, year_Number]:= Block[{}, Select[data, #[[1]]⩵ year &] ]

takeEvent[data_, event_String]:= Block[{}, Select[data, #[[15]]⩵ event &] ]

takeCountry[data_, country_String]:= Block{}, Selectdata,#[[4]]⩵ country ||#[[10]]⩵ country& 

takePlayer[data_, playerName_String]:= Block{}, (*Selectdata,#[[5]]⩵playerName||#[[11]]⩵playerName&*) Selectdata,StringContainsQ[#[[5]], playerName] || StringContainsQ[#[[11]], playerName]& 

getplayerName[data_, ID_]:= Block[{line, firstPosition, name}, line= First[FirstPosition[data, ID]]; (* that could be playerA or playerX, so please verify*) (* firstPostion= 3, is the player A, firstPosition= 9, is the player X*) firstPosition= First@FirstPosition[data[[line]], ID]; name= Which[firstPosition⩵ 3, data[[line, 5]], firstPosition⩵ 9, data[[line, 11]]]

Printed by Wolfram Mathematica Student Edition 4 ittf ranking.nb

]

findAllMatchOfPlayerName[data_, name_]:= Block[{listMixA, listMixX, listA, listX, lineA, lineX}, (* player name and country short name*) listMixA= data〚All, 5〛; listMixX= data〚All, 11〛; (* remove the country short name*) listA= StringExtract[#, 1 ;;-2]&/@ listMixA; listA= StringRiffle/@ listA; listX= StringExtract[#, 1 ;;-2]&/@ listMixX; listX= StringRiffle/@ listX; (* return the match line in the Data*) lineA= Flatten@Position[listA, name]; lineX= Flatten@Position[listX, name]; Flatten[{lineA, lineX}] ]

takeMatchBetweenPlayer[data_, name1_, name2_]:= Block{}, (* return the match results*) Selectdata, StringContainsQ[#[[5]], name1]&&StringContainsQ[#[[11]], name2] || StringContainsQ[#[[5]], name2]&&StringContainsQ[#[[11]], name1]& 

getplayerID[data_, name_]:= Block[{matchlineList, firstline, playercolumn, match, nameA, nameX, id}, matchlineList= findAllMatchOfPlayerName[data, name]; firstline= First[matchlineList]; (* that could be playerA or playerX, so please verify*) match= data〚firstline〛; {nameA, nameX} = getplayerNameFromMatch[match]; id= Which[name⩵ nameA, match〚3〛, name⩵ nameX, match〚9〛] ]

pointRun[data_]:= Block[{list, result}, (* list of{winnerID, point} *) list= matchPoint[#]&/@ data; result= List @@@ Normal[GroupBy[list, First→ Last, Total]]; Reverse[SortBy[result, Last]] ]

showRanking[data_, pointList_, topn_]:= Block[{topnData, result, title}, topnData= Take[pointList, topn]; result = {#, getplayerName[data, topnData[[#, 1]]], topnData[[#, 2]], nametoFlag[getplayerName[data, topnData[[#, 1]]]]}&/@ Range[topn]; title= "World Ranking Men Senior by EmRatThich(May- 2018)"; Labeled[Grid[result, Frame→ All], title, Top] ]

Input Data from Several Years

Printed by Wolfram Mathematica Student Edition ittf ranking.nb 5

(* inputData[{2016,2017}] *) inputData[years_List]:= Block[{fileNameList}, fileNameList= "input/" <> ToString[#]&/@ years; fileNameList= StringJoin[#, ".csv"]&/@ fileNameList; Flatten[Import/@ fileNameList, 1] ]

Input

data= inputData[{2016, 2017}];// Timing Take[data, 5] // TableForm

{5.99044, Null}

Year Tournament Player ID A 2016 2016- 11th Fajr Cup, Junior and Cadet Open, Qarvin(IRI) 131 536 2016 2016- 11th Fajr Cup, Junior and Cadet Open, Qarvin(IRI) 134 259 2016 2016- 11th Fajr Cup, Junior and Cadet Open, Qarvin(IRI) 131 522 2016 2016- 11th Fajr Cup, Junior and Cadet Open, Qarvin(IRI) 121 940

data// Length

87 690

Printed by Wolfram Mathematica Student Edition 6 ittf ranking.nb

Test

getplayerID[data, ""] takeMatchBetweenPlayer[data, "FAN Zhendong", ""]

121 404

{{2016, 2016- Men's World Cup, Saarbrucken(GER), 121 404, CHN, FAN Zhendong(CHN),,,(), 110 267, CHN, XU Xin(CHN), ,,(), Men's Singles, , 2, 4, 1, 121 404, FAN Zhendong, , , 1}, {2016, 2016- World Tour Grand Finals, (QAT), 110 267, CHN, XU Xin(CHN),,,(), 121 404, CHN, FAN Zhendong(CHN),,, (), Men's Singles, , 4, 2, 4, 121 404, FAN Zhendong, , , 1}, {2016, 2016- World Tour, Korea Open, (KOR), 110 267, CHN, XU Xin(CHN),,,(), 121 404, CHN, FAN Zhendong(CHN), ,,(), Men's Singles, , 4, 4, 3, 110 267, XU Xin, , , 1}, {2016, 2016- World Tour, Kuwait Open, (KUW), 110 267, CHN, XU Xin(CHN), 110 553, CHN, Jike(CHN), 121 404, CHN, FAN Zhendong(CHN), 105 649, CHN, MA Long(CHN), Men's Doubles, , 4, 3, 0, 110 267, XU Xin, 110 553, , 2}, {2016, 2016- World Tour, LAOX Japan Open, (JPN), 110 267, CHN, XU Xin(CHN),,,(), 121 404, CHN, FAN Zhendong(CHN),, ,(), Men's Singles, , 2, 1, 4, 121 404, FAN Zhendong, , , 1}, {2016, 2016- World Tour, Qatar Open, Doha(QAT), 110 267, CHN, XU Xin(CHN),,,(), 121 404, CHN, FAN Zhendong(CHN),,, (), Men's Singles, , 4, 2, 4, 121 404, FAN Zhendong, , , 1}, {2017, 2017- World Tour, Swedish Open, (SWE), 121 404, CHN, FAN Zhendong(CHN),,,(), 110 267, CHN, XU Xin(CHN), ,,(), Men's Singles, , 2, 1, 4, 110 267, XU Xin, , , 1}}

Run

test= takeEvent[data, "Men's Singles(Pre. Rounds)"]~ Join~takeEvent[data, "Men's Singles"]; currentRate= pointRun[test];

Top 100 Old Rating (Dec 2017) --> Make the first Old Rating (Do not run again)

Printed by Wolfram Mathematica Student Edition ittf ranking.nb 7

New Rate = 0.7 Old Rate + 0.3 Current Rate

newRateCalculate[old_, current_]:= Block[{list, result, oldcoeff, currentcoeff, old2, current2}, oldcoeff= 0.7; currentcoeff= 0.3;

old2= Transpose[{old[[All, 1]], old[[All, 2]] * oldcoeff}]; current2= Transpose[{current[[All, 1]], current[[All, 2]] * currentcoeff}];

list= Join[old2, current2]; result= List @@@ Normal[GroupBy[list, First→ Last, Total]]; Reverse[SortBy[result, Last]] ]

oldRate100= ReadList["old rate.dat",{Number, Number}]; currentRate100= Take[currentRate, 100];

newRate= newRateCalculate[oldRate100, currentRate100];

(* Top 15 Current Rate*) showRanking[test, currentRate, 20]; ListPlot[Take[currentRate[[All, 2]], 20], PlotRange→ All];

(* Top 15 New Rate*) showRanking[test, newRate, 20] ListPlot[Take[newRate[[All, 2]], 20], PlotRange→ All] Take[newRate, 20] // TableForm

Printed by Wolfram Mathematica Student Edition 8 ittf ranking.nb

World Ranking Men Senior by EmRatThich(May- 2018) 1 MA Long(CHN) 4455.72 2 FAN Zhendong(CHN) 4045.46 3 BOLL Timo(GER) 3913.26 4 OVTCHAROV Dimitrij(GER) 3624.26 5 XU Xin(CHN) 3527.82 6 MIZUTANI Jun(JPN) 3204.51 7 (CHN) 3038.07 8 CALDERANO Hugo(BRA) 2861.87 9 HARIMOTO Tomokazu(JPN) 2784.98 10 LEE Sangsu(KOR) 2777.88 11 SAMSONOV Vladimir(BLR) 2776.59 12 (HKG) 2750.51 13 FREITAS Marcos(POR) 2717.57 14 MATSUDAIRA Kenta(JPN) 2684.31 15 NIWA Koki(JPN) 2624.97 16 CHUANG Chih-Yuan(TPE) 2571.92 17 GAUZY Simon(FRA) 2566.09 18 ZHANG Jike(CHN) 2536.01 19 (CHN) 2521.13 20 ARUNA Quadri(NGR) 2437.79

4500

4000

3500

3000

2500

5 10 15 20

Printed by Wolfram Mathematica Student Edition ittf ranking.nb 9

105 649 4455.72 121 404 4045.46 101 222 3913.26 107 028 3624.26 110 267 3527.82 106 195 3204.51 115 910 3038.07 115 641 2861.87 123 980 2784.98 105 197 2777.88 108 246 2776.59 112 620 2750.51 102 841 2717.57 105 926 2684.31 110 729 2624.97 101 820 2571.92 112 062 2566.09 110 553 2536.01 111 606 2521.13 112 092 2437.79

One Event Test

swedish= Import["input/swedish open.csv"]; Take[swedish, All] // TableForm;

TableForm[takeEvent[swedish, "Men's Singles(Pre. Rounds)"]~ Join~takeEvent[swedish, "Men's Singles"]]; TableForm[takeEvent[swedish, "Men's Singles"]]; oneEvent= takeEvent[swedish, "Men's Singles"]; oneEvent// TableForm;

getNameFromMix["FAN Zhendong(CHN)"] getplayerNameFromMatch[oneEvent[[1]]]

FAN Zhendong

{FAN Zhendong, JANG Woojin}

findAllMatchOfPlayerName[oneEvent, "FAN Zhendong"] findAllMatchOfPlayerName[oneEvent, "XU Xin"] takePlayer[oneEvent, "XU Xin(CHN)"] takePlayer[oneEvent, "FAN"]

getplayerID[oneEvent, "FAN Zhendong"] takeMatchBetweenPlayer[oneEvent, "FAN Zhendong", "XU Xin"]

{1, 17, 25, 29, 31}

{16, 24, 28, 30, 31}

Printed by Wolfram Mathematica Student Edition 10 ittf ranking.nb

{{2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 101 648, TPE, CHEN Chien-An(TPE),,,(), 110 267, CHN, XU Xin(CHN), ,,(), Men's Singles, , 32, 0, 4, 110 267, XU Xin, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 123 980, JPN, HARIMOTO Tomokazu(JPN),,,(), 110 267, CHN, XU Xin(CHN), ,,(), Men's Singles, , 16, 3, 4, 110 267, XU Xin, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 112 409, DEN, GROTH Jonathan(DEN),,,(), 110 267, CHN, XU Xin(CHN), ,,(), Men's Singles, , 8, 1, 4, 110 267, XU Xin, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 111 606, CHN, FANG Bo(CHN),,,(), 110 267, CHN, XU Xin(CHN), ,,(), Men's Singles, , 4, 2, 4, 110 267, XU Xin, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 121 404, CHN, FAN Zhendong(CHN),,,(), 110 267, CHN, XU Xin(CHN), ,,(), Men's Singles, , 2, 1, 4, 110 267, XU Xin, , , 1}}

{{2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 121 404, CHN, FAN Zhendong(CHN),,,(), 114 936, KOR, JANG Woojin(KOR), ,,(), Men's Singles, , 32, 4, 0, 121 404, FAN Zhendong, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 117 890, KAZ, GERASSIMENKO Kirill(KAZ),,,(), 111 606, CHN, FANG Bo(CHN), ,,(), Men's Singles, , 32, 1, 4, 111 606, FANG Bo, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 121 404, CHN, FAN Zhendong(CHN),,,(), 116 620, GER, DUDA Benedikt(GER), ,,(), Men's Singles, , 16, 4, 1, 121 404, FAN Zhendong, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 104 379, SWE, KARLSSON Kristian(SWE),,,(), 111 606, CHN, FANG Bo(CHN), ,,(), Men's Singles, , 16, 0, 4, 111 606, FANG Bo, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 121 404, CHN, FAN Zhendong(CHN),,,(), 112 092, NGR, ARUNA Quadri(NGR), ,,(), Men's Singles, , 8, 4, 0, 121 404, FAN Zhendong, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 110 729, JPN, NIWA Koki(JPN),,,(), 111 606, CHN, FANG Bo(CHN), ,,(), Men's Singles, , 8, 3, 4, 111 606, FANG Bo, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 121 404, CHN, FAN Zhendong(CHN),,,(), 118 761, CHN, (CHN), ,,(), Men's Singles, , 4, 4, 3, 121 404, FAN Zhendong, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 111 606, CHN, FANG Bo(CHN),,,(), 110 267, CHN, XU Xin(CHN), ,,(), Men's Singles, , 4, 2, 4, 110 267, XU Xin, , , 1}, {2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 121 404, CHN, FAN Zhendong(CHN),,,(), 110 267, CHN, XU Xin(CHN), ,,(), Men's Singles, , 2, 1, 4, 110 267, XU Xin, , , 1}}

121 404

{{2017, 2017- World Tour, Swedish Open, Stockholm(SWE), 121 404, CHN, FAN Zhendong(CHN),,,(), 110 267, CHN, XU Xin(CHN), ,,(), Men's Singles, , 2, 1, 4, 110 267, XU Xin, , , 1}}

Printed by Wolfram Mathematica Student Edition ittf ranking.nb 11

Plot the ranking

nametoFlag["FAN Zhendong(VIE)"]

Rating Performance by Normal Distribution (LogisticDistribution ELO and more)

Plot[100* PDF[NormalDistribution[0, 1], x],{x, 0, 2.5}, Filling→ Axis] Round100.* PDF[NormalDistribution[0, 1],#]&/@ Range0, 2.5, 2.56

Plot[100* PDF[LogisticDistribution[0, 1], x],{x, 0, 2.5}, Filling→ Axis] Round100.* PDF[LogisticDistribution[0, 1],#]&/@ Range0, 2.5, 2.56

40

30

20

10

0.5 1.0 1.5 2.0 2.5

{40, 37, 28, 18, 10, 5, 2}

25

20

15

10

0.5 1.0 1.5 2.0 2.5

{25, 24, 21, 17, 13, 10, 7}

Printed by Wolfram Mathematica Student Edition 12 ittf ranking.nb

Input Directly the “ranking file”

M 2017 12

(* IMPORTANT NOTE*) (* File goc cua IITF, Previous Position, neu de trong se la "", no se gay loi! Do vay, can phai manually convert all "" to "0"*)

in= Import["input/ranking/M 2017 12.csv", "Table", "FieldSeparators"→ ";"]; Take[in, 5] // TableForm

in= Rest[in]; Length[in]

Position Previous position Points Player(ITTF ID) Country 1 1 3323 MA Long(105649) CHINA 2 2 3254 FAN Zhendong(121404) CHINA 3 3 3106 OVTCHAROV Dimitrij(107028) GERMANY 4 0 3078 XU Xin(110267) CHINA

1470

Age Distribution

{point, age} = {in[[All, 3]], in[[All, 7]]};

Printed by Wolfram Mathematica Student Edition ittf ranking.nb 13

opt={Frame→ True, LabelStyle→ Directive[Black, 12]}; ListPlot[age, opt, FrameLabel→{"players", "age"}] Histogram[age, opt, FrameLabel→{"age", "count"}] ListPlot[Transpose[{point, age}], opt, FrameLabel→{"ranking points", "age"}]

40

30

age 20

10

0 0 200 400 600 800 1000 1200 1400 players

250

200

150 count 100

50

0 10 15 20 25 30 35 40 age

40

30

age 20

10

0 0 500 1000 1500 2000 2500 3000 ranking points

Printed by Wolfram Mathematica Student Edition 14 ittf ranking.nb

Most Powerful country Project

Function

Printed by Wolfram Mathematica Student Edition ittf ranking.nb 15

meanPointCountry[data_, minPlayer_]:= Block[{pointList, mean, l1, l2, l3}, (* minPlayer is the minimum number require in the team. Country has less than minPlayer will be removed*) (* From the ranking data, convert to list of{country,point} *) pointList= Transpose[{data[[All, 10]], data[[All, 3]]}]; l1= List @@@ Normal[GroupBy[pointList, First→ Last]]; l2= Select[l1, Length[Last[#]]≥ minPlayer &]; l3= Transpose[{l2[[All, 1]],N[Mean/@ l2[[All, 2]]]}]; Reverse[SortBy[l3, Last]] ] showTopRankingCountry[meanPointdata_, topn_, year_, month_, nAnimation_]:= Block[{data, point, rank, name, shortname, flag, pointAnimation, shortnameAnimation, flagAnimation}, data= Take[meanPointdata, topn]; point=N[data[[All, 2]]]; rank= Range[topn]; (* {CHN,GER} *) name= data[[All, 1]]; (* {"China","Germany"} *) shortname= name/. ToShortNameRule; (* Show number 1 country on top*) point= Reverse[point]; shortname= Reverse[shortname]; rank= Reverse[rank]; (* Convert{1,2,3} to{"1","2","3"} *) rank= ToString/@ rank; (* Insert a whitespace:{"1","2","3"} to{"1 ","2 ","3 "} *) rank= StringInsert[#, " ",-1]&/@ rank; (* Display the flag*) flag= Show[CountryData[#, "Flag"], ImageSize→ 35]&/@ shortname;

(* nAnimation is to make Animation. Show only the first n Bar Chart*) pointAnimation= Join[point[[ ;; nAnimation]], Table[0, topn- nAnimation]]; shortnameAnimation= Join[shortname[[ ;; nAnimation]], Table["", topn- nAnimation]]; flagAnimation= Take[flag, nAnimation];

BarChart[pointAnimation, PlotLabel→ Style[Row[{"Top 20 Country in Table Tennis by ERT \n", DateString[{year, month},{"MonthNameShort", "-", "Year"}]}], 18, White, Background→ Black, FontFamily→ "Montserrat"], PlotRange→{{0, 2200}, All}, AxesStyle→ Directive[Orange, 12], BarOrigin→ Left, Background→ Black, ChartElementFunction -> "GlassRectangle", ChartStyle→ "BrightBands", ChartLabels→ Placed[{Style[#, 16, Bold, Black]&/@ Row/@ Transpose[{rank, shortnameAnimation}], Style[#, 14, Bold, Black]&/@ Row/@ Transpose[{flagAnimation}]},{Left, Right}], ImageSize→{720} ] ]

Printed by Wolfram Mathematica Student Edition 16 ittf ranking.nb

Median vs Mean

Median[{5, 5, 5, 5, 1.}] Mean[{5, 5, 5, 5, 1.}]

5.

4.2

Build

(* From the ranking data, convert to list of{country,point} *) pointList= Transpose[{in[[All, 10]], in[[All, 3]]}];

(* Calculate the sum points*) sum= List @@@ Normal[GroupBy[pointList, First→ Last, Total]];

(* Short by point*) Reverse[SortBy[sum, Last]];

(* Calculate the average points or Median*) sumAv= List @@@ Normal[GroupBy[pointList, First→ Last, Mean]];

(* Short by point*) Reverse[SortBy[sumAv, Last]];

(* Show number of player in each team*) lnumber= List @@@ Normal[GroupBy[pointList, First→ Last, Length]]; Reverse[SortBy[lnumber, Last]]

(* Select Team that has more than 2 players*) l1= List @@@ Normal[GroupBy[pointList, First→ Last]]; l2= Select[l1, Length[Last[#]]≥3&]; l3= Transpose[{l2[[All, 1]],N[Mean/@ l2[[All, 2]]]}]; Reverse[SortBy[l3, Last]]

Printed by Wolfram Mathematica Student Edition ittf ranking.nb 17

{{EGY, 58},{JPN, 50},{SWE, 46},{FRA, 45},{RUS, 41},{POL, 38},{SRB, 37}, {KOR, 36},{CZE, 35},{TPE, 32},{ESP, 32},{ROU, 31},{CHN, 30},{SVK, 29}, {NGR, 28},{IND, 28},{GER, 28},{CRO, 28},{BUL, 26},{SLO, 25},{HKG, 24}, {ITA, 23},{BRA, 22},{BLR, 21},{HUN, 20},{BEL, 19},{AUT, 19},{AUS, 19}, {ARG, 19},{POR, 18},{IRI, 18},{SGP, 17},{ENG, 17},{CHI, 17},{USA, 16}, {KSA, 16},{THA, 15},{GRE, 15},{DEN, 15},{CAN, 15},{UKR, 14},{SUI, 12}, {LUX, 12},{ISR, 12},{TUN, 11},{PRK, 11},{NZL, 9},{MEX, 9},{TUR, 8}, {SCO, 8},{QAT, 8},{NOR, 8},{LTU, 8},{EST, 8},{BIH, 8},{PUR, 7},{PER, 7}, {KAZ, 7},{JOR, 7},{FIN, 7},{COL, 7},{SRI, 6},{SMR, 6},{MNE, 6},{MAS, 6}, {LAT, 6},{GUA, 6},{CUB, 6},{CGO, 6},{NED, 5},{KOS, 5},{IRL, 5},{INA, 5}, {ESA, 5},{ECU, 5},{DOM, 5},{ALG, 5},{WAL, 4},{VIE, 4},{VEN, 4},{PAR, 4}, {MDA, 4},{MAR, 4},{FIJ, 4},{COD, 4},{URU, 3},{UAE, 3},{TTO, 3},{RSA, 3}, {PHI, 3},{PAK, 3},{MGL, 3},{MAC, 3},{LAO, 3},{GHA, 3},{CYP, 3},{CMR, 3}, {CAM, 3},{BAR, 3},{AZE, 3},{ARU, 3},{UZB, 2},{SEY, 2},{SEN, 2},{PYF, 2}, {PAN, 2},{NCL, 2},{MYA, 2},{MLT, 2},{KGZ, 2},{JAM, 2},{IRQ, 2}, {CRC, 2},{CIV, 2},{BAN, 2},{YEM, 1},{VAN, 1},{TUV, 1},{TOG, 1}, {TKM, 1},{NEP, 1},{MRI, 1},{MKD, 1},{MDV, 1},{MAD, 1},{LCA, 1}, {LBN, 1},{JEY, 1},{GUY, 1},{GAB, 1},{DJI, 1},{COK, 1},{ANG, 1}}

{{CHN, 2078.07},{JPN, 1826.82},{KOR, 1590.92},{GER, 1588.57}, {FRA, 1563.27},{PRK, 1528.73},{TPE, 1483.84},{POR, 1393.94}, {RUS, 1365.93},{BRA, 1327.86},{NED, 1288.6},{UKR, 1286.36},{IND, 1285.71}, {CUB, 1281.33},{BEL, 1279.32},{ENG, 1274.53},{AUT, 1243.74},{TUR, 1242.25}, {GRE, 1214.6},{MAC, 1208.33},{DOM, 1201.},{VIE, 1197.75},{SWE, 1177.85}, {HKG, 1175.75},{PAR, 1170.75},{HUN, 1153.8},{IRI, 1148.33},{PHI, 1111.}, {POL, 1096.45},{CZE, 1088.66},{AZE, 1078.},{DEN, 1072.13},{CYP, 1067.33}, {LTU, 1066.5},{NGR, 1054.82},{SGP, 1054.18},{PAK, 1052.67},{SVK, 1045.17}, {PUR, 1044.43},{ARG, 1044.37},{ITA, 1039.87},{BLR, 1028.29}, {RSA, 1028.},{IRL, 1025.2},{INA, 1024.8},{LUX, 1012.92},{LAT, 1008.67}, {SCO, 1001.13},{ESP, 994.75},{SRI, 990.833},{USA, 982.5},{ISR, 980.25}, {MEX, 966.889},{CHI, 962.059},{COL, 956.143},{MAS, 941.667},{VEN, 935.}, {KAZ, 927.429},{ECU, 927.2},{CAN, 902.733},{THA, 902.667},{MAR, 901.5}, {BAR, 893.},{GHA, 881.333},{ROU, 880.129},{PER, 874.286},{MDA, 861.5}, {FIN, 837.429},{EST, 831.875},{CGO, 825.167},{CRO, 820.214},{NOR, 810.25}, {AUS, 806.474},{SUI, 806.},{SLO, 803.12},{GUA, 790.333},{BIH, 785.}, {ALG, 778.2},{MGL, 773.667},{BUL, 761.577},{TTO, 734.},{CMR, 716.333}, {MNE, 713.167},{URU, 694.333},{SRB, 693.514},{NZL, 675.},{TUN, 665.364}, {QAT, 645.125},{WAL, 589.75},{KOS, 578.6},{JOR, 571.857},{UAE, 568.333}, {SMR, 555.833},{EGY, 550.172},{KSA, 532.563},{LAO, 454.667}, {ESA, 436.},{COD, 337.},{ARU, 292.667},{FIJ, 215.},{CAM, 197.667}}

Printed by Wolfram Mathematica Student Edition 18 ittf ranking.nb

showTopRankingCountry[meanPointCountry[in, 3], 10, 2017, 12, 5]

Input from the ranking of many years

all= Import["input/ranking/M.csv", "Table", "FieldSeparators"→ ";"]; Take[all, 5] // TableForm

all= Rest[all]; Length[all]

Position Previous position Points Player(ITTF ID) Country Gender 1 1 3099 MA Long(105649) CHINA Male 2 2 3093 XU Xin(110267) CHINA Male 3 3 2894 ZHANG Jike(110553) CHINA Male 4 5 2883 FAN Zhendong(121404) CHINA Male

66 915

LengthSelectall,#[[8]]⩵ "February"&&#[[9]]⩵ 2014&

1791

Printed by Wolfram Mathematica Student Edition ittf ranking.nb 19

DateString[{2017, 2}, "MonthName"]

February

takeDatafromMainData[maindata_, month_, year_]:= Block{monthString}, monthString= DateString[{year, month}, "MonthName"]; Selectmaindata,#[[8]]⩵ monthString&&#[[9]]⩵ year& 

From Main Data

data2015= takeDatafromMainData[all, 8, 2016]; showTopRankingCountry[meanPointCountry[data2015, 4], 10, 2015, 5, 10]

Printed by Wolfram Mathematica Student Edition