(* ::Package:: *)
Needs["ErrorBarPlots`"]
gsraw=Import[NotebookDirectory[]<>"data/graphdata_etmt_partial.m"];
(* gsraw=SortBy[gsraw,{#[[1,1]]&,#[[1,2]]&}]; (* Sort by n and then by tau. The {} forces a *stable* sort because otherwise Mathematica sorts also on triangle count and other things. *) *)
gdata=GatherBy[gsraw,{#[[1,2]]&,#[[1,1]]&}];
(* Data format: *)
(* gdata[[ tau index, n index, run index , datatype index ]] *)
(* datatype index:
1: {n,tau}
2: etmt
*)
nlabels=Map["n = "<>ToString[#]&,gdata[[1,All,1,1,1]]];
taulabels=Map["\[Tau] = "<>ToString[#]&,gdata[[All,1,1,1,2]]];
histograms=Map[Histogram[#[[All,2]]]&,gdata,{2}];
histogramsWithLine=Map[Histogram[#[[All,2]],Epilog->Line[{{Mean[N[#[[All,2]]]]+StandardDeviation[N[#[[All,2]]]],0},{Mean[N[#[[All,2]]]]+StandardDeviation[N[#[[All,2]]]],500}}]]&,gdata,{2}];
TableForm[histograms,TableHeadings->{taulabels,nlabels}]
gdataSwitched=Transpose[gdata];
tauChoices={1,3,5,7,9};
combiHistograms=Map[SmoothHistogram[#[[tauChoices,All,2]],PlotRange->All,PlotLegends->taulabels[[tauChoices]],PlotLabel->"n = "<>ToString[#[[1,1,1,1]]]]&,gdataSwitched,{1}];
combiHistograms[[9]]
Export[NotebookDirectory[]<>"plots/ETMTdistribution.pdf",combiHistograms[[9]]]
mixingTimesBars=Map[{{#[[1,1,1]],Mean[#[[All,2]]]},ErrorBar[StandardDeviation[#[[All,2]]]]}&,gdata,{2}];
ErrorListPlot[mixingTimesBars[[{1,2,3,5,8}]],Joined->True,PlotMarkers->Automatic,Frame->True,FrameLabel->{"n","ETMT"},PlotLegends->taulabels]
mixingTimesDivN=Map[{#[[1,1]],#[[1,2]]/(#[[1,1]])}&,mixingTimesBars,{2}];
mixingTimesDivNlogN=Map[{#[[1,1]],#[[1,2]]/(#[[1,1]]*Log[#[[1,1]]])}&,mixingTimesBars,{2}];
plotN=ListPlot[mixingTimesDivN,Joined->True,PlotMarkers->Automatic,Frame->True,FrameLabel->{"n","\[LeftAngleBracket]ETMT\[RightAngleBracket]/n"},PlotLegends->taulabels,ImageSize->300]
plotNlogN=ListPlot[mixingTimesDivNlogN,Joined->True,PlotMarkers->Automatic,Frame->True,FrameLabel->{"n","\[LeftAngleBracket]ETMT\[RightAngleBracket]/(n log n)"},PlotLegends->taulabels,ImageSize->300]
Export[NotebookDirectory[]<>"plots/ETMTdivN.pdf",plotN]