Changeset - d0cb8a9f1b0e
[Not reviewed]
0 1 0
Tom Bannink - 8 years ago 2017-05-08 14:21:48
tombannink@gmail.com
Add error bars to triangle exponent plot
1 file changed with 24 insertions and 2 deletions:
0 comments (0 inline, 0 general)
showgraphs.m
Show inline comments
 
@@ -173,85 +173,107 @@ getMixingTime[values_]:=Module[{avg},
 
]
 
(* gdata[[ tau index, n index, run index , {ntau, #tris, ds} ]] *)
 
measureSkip=1;
 
mixingTimes=Map[{#[[1,1]],(1/#[[1,1]])measureSkip * getMixingTime[#[[2]]]}&,gdata,{3}];
 
mixingTimesBars=Map[
 
    {{#[[1,1]],Mean[#[[All,2]]]},ErrorBar[StandardDeviation[#[[All,2]]]/Sqrt[Length[#]]]}&
 
,mixingTimes,{2}];
 
ErrorListPlot[mixingTimesBars,Joined->True,PlotMarkers->Automatic,AxesLabel->{"n","~~mixing time divided by n"},PlotLegends->taulabels]
 

	
 

	
 
(* For n fixed, look at function of tau *)
 
measureSkip=1;
 
mixingTimes=Map[{#[[1,2]],(1/#[[1,1]])measureSkip * getMixingTime[#[[2]]]}&,gdata,{3}];
 
mixingTimesBars=Map[
 
    {{#[[1,1]],Mean[#[[All,2]]]},ErrorBar[StandardDeviation[#[[All,2]]]]}&
 
,mixingTimes[[All,-1]],{1}];
 

	
 

	
 
Show[
 
ErrorListPlot[mixingTimesBars,Joined->True,PlotMarkers->Automatic,AxesLabel->{"tau","~~mixing time divided by n, for n = 1000"},PlotRange->{{2,3},{0,30}}]
 
,Plot[(32-26(tau-2)),{tau,2,3}]]
 

	
 

	
 
(* ::Subsection:: *)
 
(*Plot average #triangles vs n*)
 
(*Triangle exponent: Plot average #triangles vs n*)
 

	
 

	
 
(* When importing from exponent-only-data file *)
 
gsraw=Import[NotebookDirectory[]<>"data/graphdata_partial.m"];
 
gsraw=SortBy[gsraw,#[[1,1]]&]; (* Sort by n *)
 
averagesGrouped=GatherBy[gsraw,{#[[1,2]]&,#[[1,1]]&}];
 

	
 

	
 
(* When importing from general file *)
 
averages=Map[{#[[1]],Mean[#[[2,1;;-1]]]}&,gsraw];
 
(* averages=SortBy[averages,#[[1,1]]&]; (* Sort by n *) *)
 
averagesGrouped=GatherBy[averages,{#[[1,2]]&,#[[1,1]]&}]; (* Split by n,tau *)
 

	
 

	
 
(* averagesGrouped[[ tau index, n index, run index , {ntau, avgtri} ]] *)
 
nlabels=Map["n = "<>ToString[#]&,averagesGrouped[[1,All,1,1,1]]];
 
taulabels=Map["tau = "<>ToString[#]&,averagesGrouped[[All,1,1,1,2]]];
 
averagesErrorBars=Map[
 
{{#[[1,1,1]],Mean[#[[All,2]]]},
 
ErrorBar[StandardDeviation[#[[All,2]]]]
 
}&,averagesGrouped,{2}];
 

	
 

	
 
ErrorListPlot[averagesErrorBars,Joined->True,PlotMarkers->Automatic,PlotRange->All,AxesLabel->{"n","\[LeftAngleBracket]triangles\[RightAngleBracket]"},PlotLegends->taulabels]
 

	
 

	
 
ListLogLogPlot[averagesErrorBars[[All,All,1]],Joined->True,PlotMarkers->Automatic,AxesLabel->{"n","\[LeftAngleBracket]triangles\[RightAngleBracket]"},PlotLegends->taulabels]
 

	
 

	
 
(* ::Subsection:: *)
 
(*Fitting the log-log-plot*)
 

	
 

	
 
loglogdata=Log[averagesErrorBars[[All,All,1]]];
 
fits=Map[Fit[#,{1,logn},logn]&,loglogdata];
 
fitsExtra=Map[LinearModelFit[#,logn,logn]&,loglogdata];
 

	
 

	
 
Show[ListLogLogPlot[averagesErrorBars[[All,All,1]],PlotMarkers->Automatic,AxesLabel->{"n","\[LeftAngleBracket]triangles\[RightAngleBracket]"},PlotLegends->taulabels],Plot[fits,{logn,1,2000}]]
 
fitsExtra[[1]]["ParameterConfidenceIntervalTable"]
 
fitsExtra[[1]]["BestFitParameters"]
 
fitsExtra[[1]]["ParameterErrors"]
 
fitsExtra[[1]]["ParameterConfidenceIntervals"]
 

	
 

	
 
Show[ListLogLogPlot[averagesErrorBars[[All,All,1]],Joined->True,PlotMarkers->Automatic,AxesLabel->{"n","\[LeftAngleBracket]triangles\[RightAngleBracket]"},PlotLegends->taulabels],Plot[fits,{logn,1,2000}]]
 

	
 

	
 
tauValues=averagesGrouped[[All,1,1,1,2]];
 
exponents=Transpose[{tauValues,fits[[All,2,1]]}];
 
Show[ListPlot[exponents,Joined->True,PlotMarkers->Automatic,AxesLabel->{"tau","triangle-law-exponent"},PlotRange->{{2,3},{0,1.6}}],Plot[3/2(3-tau),{tau,2,3}]]
 

	
 

	
 
tauValues=averagesGrouped[[All,1,1,1,2]];
 
exponentsErrorBars=Map[{{#[[1]],#[[2]]["BestFitParameters"][[2]]},ErrorBar[#[[2]]["ParameterConfidenceIntervals"][[2]]-#[[2]]["BestFitParameters"][[2]]]}&,
 
Transpose[{tauValues,fitsExtra}]];
 
Show[ErrorListPlot[exponentsErrorBars,Joined->True,PlotMarkers->Automatic,AxesLabel->{"tau","triangle-law-exponent"},PlotRange->{{2,3},{0,1.6}}],Plot[3/2(3-tau),{tau,2,3}]]
 

	
 

	
 
(* ::Subsection:: *)
 
(*Plot #triangles distribution for specific (n,tau)*)
 

	
 

	
 
plotRangeByTau[tau_]:=Piecewise[{{{0,30000},tau<2.3},{{0,4000},2.3<tau<2.7},{{0,800},tau>2.7}},Automatic]
 
histograms=Map[Histogram[#[[All,2]],PlotRange->{plotRangeByTau[#[[1,1,2]]],Automatic}]&,averagesGrouped,{2}];
 

	
 

	
 
(* TableForm[histograms,TableHeadings->{taulabels,nlabels}] *)
 
TableForm[Transpose[histograms],TableHeadings->{nlabels,taulabels}]
 

	
 

	
 
(* ::Section:: *)
 
(*Greedy configuration model*)
 

	
 

	
 
(* ::Subsection:: *)
 
(*#triangles(GCM) distribution vs #triangles(SwitchChain)*)
 

	
 

	
 
timeWindow=Round[Length[gdata[[1,1,1,2]]]/10];
 
getStats[run_]:=Module[{avg,stddev},
 
    avg=N[Mean[run[[2,-timeWindow;;-1]]]];
 
    stddev=N[StandardDeviation[run[[2,timeWindow;;-1]]]];
0 comments (0 inline, 0 general)