From 5cec3a409ef3c6f2e6cbaf781007c9168878d843 2017-06-12 17:26:59 From: Tom Bannink Date: 2017-06-12 17:26:59 Subject: [PATCH] Add triangle creation frequency plots --- diff --git a/triangle_analysis.m b/triangle_analysis.m index 5243b5e2cdbd692e2618b3c65949c2b0c39039be..e972a7a311431b897ad816f8955efaa20e4d814c 100644 --- a/triangle_analysis.m +++ b/triangle_analysis.m @@ -193,6 +193,10 @@ plotTimeEvol=ListPlot[coarseData,Joined->True,PlotRange->{0*minCount,maxCount},D Export[NotebookDirectory[]<>"plots/timeevol.pdf",plotTimeEvol] +movingAvg=Map[MovingAverage[#[[2]],2000][[1;;-1;;skipPts]]-Mean[#[[2,-20000;;-1]]]&,selectedData[[1;;-1;;5]]]; +plotMovingAvg=ListPlot[movingAvg,Joined->True,PlotRange->All,DataRange->{0,measureSkip*maxTime},Frame->True,FrameLabel->{"timesteps","number of triangles"}] + + (* ::Subsection:: *) (*Plot success rate over "time"*) diff --git a/triangle_creation_frequency_plots.m b/triangle_creation_frequency_plots.m new file mode 100644 index 0000000000000000000000000000000000000000..247cd547a4da1eaab8b7ef52b6289bfdd0e3106c --- /dev/null +++ b/triangle_creation_frequency_plots.m @@ -0,0 +1,54 @@ +(* ::Package:: *) + +Needs["ErrorBarPlots`"] + + +(* ::Section:: *) +(*Data import*) + + +gsraw=Import[NotebookDirectory[]<>"data/graphdata_timeevol.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: #triangles time sequence +*) +nlabels=Map["n = "<>ToString[#]&,gdata[[1,All,1,1,1]]]; +taulabels=Map["tau = "<>ToString[#]&,gdata[[All,1,1,1,2]]]; + + +(* ::Section:: *) +(*Triangle creation frequencies*) + + +(* ::Subsection:: *) +(*Plot triangle count over "time" in Markov chain instances*) + + +numPlots=20; +selectedData=gdata[[1,1]][[-numPlots;;-1]]; +measureSkip=1; +minCount=Min[Map[Min[#[[2]]]&,selectedData]]; +maxCount=Max[Map[Max[#[[2]]]&,selectedData]]; +maxTime=Max[Map[Length[#[[2]]]&,selectedData]]; +(* maxTime=30000; *) +skipPts=Max[1,Round[maxTime/500]]; (* Plotting every point is slow. Plot only once per `skipPts` timesteps *) +coarseData=Map[#[[2,1;;maxTime;;skipPts]]&,selectedData]; +labels=Map["{n,tau} = "<>ToString[#[[1]]]&,selectedData]; +ListPlot[coarseData,Joined->True,PlotRange->{0*minCount,maxCount},DataRange->{0,measureSkip*maxTime},PlotLegends->labels] +(* Map[ListPlot[#,Joined->True,PlotRange\[Rule]{minCount,maxCount},DataRange\[Rule]{0,maxTime}]&,coarseData] *) + + +differences=Map[Differences[#[[2,25000;;-1]]]&,gdata,{3}]; + + +(* Take three runs of each *) +histograms=Map[Histogram[#[[{1,6,11,16}]],{-20,20,1},"LogCount",ImageSize->300]&,differences,{2}]; + + +TableForm[histograms,TableHeadings->{taulabels,nlabels}] diff --git a/triangle_spectrum_plots.m b/triangle_spectrum_plots.m new file mode 100644 index 0000000000000000000000000000000000000000..2fbbd2afd660a1d7fb4b82a8b5c7240057f93cf4 --- /dev/null +++ b/triangle_spectrum_plots.m @@ -0,0 +1,27 @@ +(* ::Package:: *) + +gsraw=Import[NotebookDirectory[]<>"cpp/graphdata_spectrum.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 +*) +tauvalues=gdata[[All,1,1,1,2]]; +nlabels=Map["n = "<>ToString[#]&,gdata[[1,All,1,1,1]]]; +taulabels=Map["\[Tau] = "<>ToString[#]&,gdata[[All,1,1,1,2]]]; + + +ListPlot[gdata[[1,1,1,{4,6}]]] +ListPlot[gdata[[1,1,1,{5,7}]]] + + +Histogram[gdata[[1,1,1,{4,6}]],50] +Histogram[gdata[[1,1,1,{5,7}]],50] + + +