Changeset - d99b1ddf4d24
[Not reviewed]
0 2 0
Tom Bannink - 8 years ago 2017-10-12 14:56:01
tom.bannink@cwi.nl
Add MaTeX plot label to triangle-exponent plot
2 files changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
plots/triangle_exponent.pdf
Show inline comments
 
binary diff not shown
triangle_ecm_initialtris.m
Show inline comments
 
@@ -107,103 +107,103 @@ sdECM=mySD[run[[3]]];
 
{{n,avgECM},ErrorBar[sdECM]}
 
}
 
]
 
allErrorBars=Map[getErrorBars,gdata,{2}];
 

	
 

	
 
Map[ErrorListPlot[Transpose[#],
 
ImageSize->500,
 
Frame->True,
 
PlotMarkers->Automatic
 
]&,allErrorBars[[{1,6,11}]]]
 

	
 

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

	
 

	
 
nRange=All;
 

	
 
(* Weight: 1/err^2 *)
 
(* Weight: N/Total[(xs-Mean[xs])^2] *)
 
getWeight[xs_]:=1/(Log[Mean[xs]]-Log[Mean[xs]-Sqrt[Total[(xs-Mean[xs])^2]/Length[xs]]])^2;
 
(* Several runs for fixed tau but different n *)
 
getFitData[runs_,index_]:=Map[{Log[#[[1,1]]],Log[Mean[#[[index]]]],getWeight[#[[index]]]}&,runs];
 

	
 
uniformFitData=Map[getFitData[#,2]&,gdata[[All,nRange]]];
 
ECMFitData=Map[getFitData[#,3]&,gdata[[All,nRange]]];
 

	
 
uniformFits=Map[LinearModelFit[#[[All,{1,2}]],logn,logn(*,Weights\[Rule]#[[All,3]]*)]&,uniformFitData];
 
ECMFits=    Map[LinearModelFit[#[[All,{1,2}]],logn,logn(*,Weights\[Rule]#[[All,3]]*)]&,ECMFitData];
 
(*
 
uniformloglog=Log[dataPointsUniform[[All,nRange]]];
 
ECMloglog=Log[dataPointsECM[[All,nRange]]];
 

	
 
uniformFits=Map[LinearModelFit[#,logn,logn]&,uniformloglog];
 
ECMFits=Map[LinearModelFit[#,logn,logn]&,ECMloglog];
 
*)
 
uniformFuncs=Map[#[logn]&,uniformFits];
 
ECMFuncs=Map[#[logn]&,ECMFits];
 

	
 

	
 
uniformFits[[1]]["ParameterTable"] (* Get `Standard Error' by "ParameterErrors" *)
 
uniformFits[[1]]["ParameterConfidenceIntervalTable"] (* Get confidence by "ParameterConfidenceIntervals *)
 
(* estimate +- standard error *)
 
uniformFits[[1]]["BestFitParameters"]-uniformFits[[1]]["ParameterErrors"]
 
uniformFits[[1]]["BestFitParameters"]+uniformFits[[1]]["ParameterErrors"]
 

	
 

	
 
tauChoices={1,4,6,8,11};
 
taulabels=Map["\[Tau] = "<>ToString[NumberForm[#[[1,1,2]],{3,2}]]&,gdata[[tauChoices]]];
 

	
 
repeatColors[n_,k_]:=Table[ColorData[97][Mod[i,k,1]],{i,1,n}]
 

	
 
plot1=Show[ListLogLogPlot[Evaluate[dataPointsUniform[[tauChoices]]~Join~dataPointsECM[[tauChoices]]],
 
Frame->True,
 
FrameTicks->{{Table[{10^k,Superscript[10,k]},{k,0,6}],Automatic},{{1000,2000,5000,10000},Automatic}},
 
FrameLabel->{"n","triangles"},
 
ImageSize->250,
 
PlotMarkers->Automatic,
 
PlotLegends->taulabels,
 
PlotStyle->repeatColors[10,5]
 
],
 
Plot[Evaluate[uniformFuncs[[tauChoices]]],{logn,1,20000}],
 
Plot[Evaluate[ECMFuncs[[tauChoices]]],{logn,1,20000}]
 
]
 

	
 

	
 
Export[NotebookDirectory[]<>"plots/avgtris_n.pdf",plot1]
 

	
 

	
 
(* ::Subsection:: *)
 
(*T(\[Tau]) including error bars*)
 

	
 

	
 
gsraw2=Import[NotebookDirectory[]<>"data/graphdata_exponent_hightau.m"];
 
gsraw2=SortBy[gsraw2,#[[1,1]]&]; (* Sort by n *)
 
averagesGrouped=GatherBy[gsraw2,{#[[1,2]]&,#[[1,1]]&}];
 
averagesLoglogdata=Map[{Log[#[[1,1,1]]],Log[Mean[#[[All,2]]]]}&,averagesGrouped[[All,nRange]],{2}];
 
averagesFitsExtra=Map[LinearModelFit[#,logn,logn]&,averagesLoglogdata];
 
avgTauValues=averagesGrouped[[All,1,1,1,2]];
 
averagesExponentsErrorBars=Map[{{#[[1]],#[[2]]["BestFitParameters"][[2]]},ErrorBar[#[[2]]["ParameterConfidenceIntervals"][[2]]-#[[2]]["BestFitParameters"][[2]]]}&,
 
Transpose[{avgTauValues-0.000,averagesFitsExtra}]];
 

	
 

	
 
tauValues=gdata[[All,1,1,2]];
 

	
 
(* For visual, shift the tau values slightly left or right to distinguish the two datasets *)
 
uniformExponents=Map[{{#[[1]],#[[2]]["BestFitParameters"][[2]]},ErrorBar[#[[2]]["ParameterConfidenceIntervals"][[2]]-#[[2]]["BestFitParameters"][[2]]]}&, Transpose[{tauValues+0.000,uniformFits}]];
 
ECMExponents    =Map[{{#[[1]],#[[2]]["BestFitParameters"][[2]]},ErrorBar[#[[2]]["ParameterConfidenceIntervals"][[2]]-#[[2]]["BestFitParameters"][[2]]]}&, Transpose[{tauValues+0.000,ECMFits}]];
 

	
 
Needs["MaTeX`"]
 

	
 
plot2=Show[
 
ErrorListPlot[{ECMExponents,uniformExponents,averagesExponentsErrorBars},
 
Joined->True,PlotMarkers->Automatic,
 
PlotLegends->Placed[{"ECM","canonical","average"},{Left,Bottom}],
 
Frame->True,FrameLabel->{"tau","triangle powerlaw exponent"},
 
Frame->True,FrameLabel->{MaTeX["\\tau"],"triangle powerlaw exponent"},
 
PlotRange->{{2,3},{0,1.6}},
 
ImageSize->300],
 
Plot[3/2(3-tau),{tau,2,3},PlotStyle->{Black,Dashed},PlotLegends->Placed[LineLegend[{MaTeX["\\frac{3}{2}(3-\\tau)"]},LegendMarkerSize->20],{Left,Bottom}]]]
 

	
 

	
 
Export[NotebookDirectory[]<>"plots/triangle_exponent.pdf",plot2]
0 comments (0 inline, 0 general)