path="c:/users/dre2/desktop/DRYGINresubmission/";

dim=17;

(* Go back from exponential binning to linear scale and plot: number of points, average deviation from the linear model, variance and standard deviation. Group D *)

npointstot=Table[0,{dim},{dim}];
delta1tot=Table[0,{dim},{dim}];
delta2tot=Table[0,{dim},{dim}];
binxtot=Table[0,{dim}];
nxtot=Table[0,{dim}];

npoints=Import[StringJoin[path,"FILES2012/j1d_npointsD_fake_studentt.dat"]];
delta1=Import[StringJoin[path,"FILES2012/j1d_delta1D_fake_studentt.dat"]];
delta2=Import[StringJoin[path,"FILES2012/j1d_delta2D_fake_studentt.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/j1d_binxD_fake_studentt.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/j1d_nxD_fake_studentt.dat"]]];

For[i=1,i≤dim,i++,
nxtot[[i]]+=nx[[i]];
binxtot[[i]]+=binx[[i]];
]
For[i=1,i≤dim,i++,
For[j=1,j≤dim,j++,
npointstot[[i,j]]+=npoints[[i,j]];
delta1tot[[i,j]]+=delta1[[i,j]];
delta2tot[[i,j]]+=delta2[[i,j]];
];
]

npoints=Import[StringJoin[path,"FILES2012/j2d_npointsD_fake_studentt.dat"]];
delta1=Import[StringJoin[path,"FILES2012/j2d_delta1D_fake_studentt.dat"]];
delta2=Import[StringJoin[path,"FILES2012/j2d_delta2D_fake_studentt.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/j2d_binxD_fake_studentt.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/j2d_nxD_fake_studentt.dat"]]];

For[i=1,i≤dim,i++,
nxtot[[i]]+=nx[[i]];
binxtot[[i]]+=binx[[i]];
]
For[i=1,i≤dim,i++,
For[j=1,j≤dim,j++,
npointstot[[i,j]]+=npoints[[i,j]];
delta1tot[[i,j]]+=delta1[[i,j]];
delta2tot[[i,j]]+=delta2[[i,j]];
];
]

npoints=Import[StringJoin[path,"FILES2012/j3d_npointsD_fake_studentt.dat"]];
delta1=Import[StringJoin[path,"FILES2012/j3d_delta1D_fake_studentt.dat"]];
delta2=Import[StringJoin[path,"FILES2012/j3d_delta2D_fake_studentt.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/j3d_binxD_fake_studentt.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/j3d_nxD_fake_studentt.dat"]]];

For[i=1,i≤dim,i++,
nxtot[[i]]+=nx[[i]];
binxtot[[i]]+=binx[[i]];
]
For[i=1,i≤dim,i++,
For[j=1,j≤dim,j++,
npointstot[[i,j]]+=npoints[[i,j]];
delta1tot[[i,j]]+=delta1[[i,j]];
delta2tot[[i,j]]+=delta2[[i,j]];
];
]

npoints=Import[StringJoin[path,"FILES2012/j4d_npointsD_fake_studentt.dat"]];
delta1=Import[StringJoin[path,"FILES2012/j4d_delta1D_fake_studentt.dat"]];
delta2=Import[StringJoin[path,"FILES2012/j4d_delta2D_fake_studentt.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/j4d_binxD_fake_studentt.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/j4d_nxD_fake_studentt.dat"]]];

For[i=1,i≤dim,i++,
nxtot[[i]]+=nx[[i]];
binxtot[[i]]+=binx[[i]];
]
For[i=1,i≤dim,i++,
For[j=1,j≤dim,j++,
npointstot[[i,j]]+=npoints[[i,j]];
delta1tot[[i,j]]+=delta1[[i,j]];
delta2tot[[i,j]]+=delta2[[i,j]];
];
]

npoints=Import[StringJoin[path,"FILES2012/j5d_npointsD_fake_studentt.dat"]];
delta1=Import[StringJoin[path,"FILES2012/j5d_delta1D_fake_studentt.dat"]];
delta2=Import[StringJoin[path,"FILES2012/j5d_delta2D_fake_studentt.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/j5d_binxD_fake_studentt.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/j5d_nxD_fake_studentt.dat"]]];

For[i=1,i≤dim,i++,
nxtot[[i]]+=nx[[i]];
binxtot[[i]]+=binx[[i]];
]
For[i=1,i≤dim,i++,
For[j=1,j≤dim,j++,
npointstot[[i,j]]+=npoints[[i,j]];
delta1tot[[i,j]]+=delta1[[i,j]];
delta2tot[[i,j]]+=delta2[[i,j]];
];
]

npoints=Import[StringJoin[path,"FILES2012/j6d_npointsD_fake_studentt.dat"]];
delta1=Import[StringJoin[path,"FILES2012/j6d_delta1D_fake_studentt.dat"]];
delta2=Import[StringJoin[path,"FILES2012/j6d_delta2D_fake_studentt.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/j6d_binxD_fake_studentt.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/j6d_nxD_fake_studentt.dat"]]];

For[i=1,i≤dim,i++,
nxtot[[i]]+=nx[[i]];
binxtot[[i]]+=binx[[i]];
]
For[i=1,i≤dim,i++,
For[j=1,j≤dim,j++,
npointstot[[i,j]]+=npoints[[i,j]];
delta1tot[[i,j]]+=delta1[[i,j]];
delta2tot[[i,j]]+=delta2[[i,j]];
];
]

npoints=Import[StringJoin[path,"FILES2012/j7d_npointsD_fake_studentt.dat"]];
delta1=Import[StringJoin[path,"FILES2012/j7d_delta1D_fake_studentt.dat"]];
delta2=Import[StringJoin[path,"FILES2012/j7d_delta2D_fake_studentt.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/j7d_binxD_fake_studentt.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/j7d_nxD_fake_studentt.dat"]]];

For[i=1,i≤dim,i++,
nxtot[[i]]+=nx[[i]];
binxtot[[i]]+=binx[[i]];
]
For[i=1,i≤dim,i++,
For[j=1,j≤dim,j++,
npointstot[[i,j]]+=npoints[[i,j]];
delta1tot[[i,j]]+=delta1[[i,j]];
delta2tot[[i,j]]+=delta2[[i,j]];
];
]

npoints=Import[StringJoin[path,"FILES2012/j8d_npointsD_fake_studentt.dat"]];
delta1=Import[StringJoin[path,"FILES2012/j8d_delta1D_fake_studentt.dat"]];
delta2=Import[StringJoin[path,"FILES2012/j8d_delta2D_fake_studentt.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/j8d_binxD_fake_studentt.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/j8d_nxD_fake_studentt.dat"]]];

For[i=1,i≤dim,i++,
nxtot[[i]]+=nx[[i]];
binxtot[[i]]+=binx[[i]];
]
For[i=1,i≤dim,i++,
For[j=1,j≤dim,j++,
npointstot[[i,j]]+=npoints[[i,j]];
delta1tot[[i,j]]+=delta1[[i,j]];
delta2tot[[i,j]]+=delta2[[i,j]];
];
]

npoints=Import[StringJoin[path,"FILES2012/j9d_npointsD_fake_studentt.dat"]];
delta1=Import[StringJoin[path,"FILES2012/j9d_delta1D_fake_studentt.dat"]];
delta2=Import[StringJoin[path,"FILES2012/j9d_delta2D_fake_studentt.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/j9d_binxD_fake_studentt.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/j9d_nxD_fake_studentt.dat"]]];

For[i=1,i≤dim,i++,
nxtot[[i]]+=nx[[i]];
binxtot[[i]]+=binx[[i]];
]
For[i=1,i≤dim,i++,
For[j=1,j≤dim,j++,
npointstot[[i,j]]+=npoints[[i,j]];
delta1tot[[i,j]]+=delta1[[i,j]];
delta2tot[[i,j]]+=delta2[[i,j]];
];
]

(* end of file reading ; begin of plotting *)

npoints=npointstot;
delta1=delta1tot;
delta2=delta2tot;
binx=binxtot;
nx=nxtot;

meanx=Table[0,{dim}];
For[i=1,i≤dim,i++,
If[nx[[i]]≠0,meanx[[i]]=((binx[[i]])/(nx[[i]])),meanx[[i]]=Null];
]

nangrid={};
eps0={};
eps1={};
eps2={};
epssigma={};

For[i=1,i≤dim,i++,
For[j=1,j≤dim,j++,

x=meanx[[i]];
y=meanx[[j]];

If[npoints[[i,j]]>1,
AppendTo[eps0,{x,y,Log[10,npoints[[i,j]]]}];
AppendTo[eps1,{x,y,((delta1[[i,j]])/(npoints[[i,j]]))}];
AppendTo[eps2,{x,y,((delta2[[i,j]])/(npoints[[i,j]]))}];
AppendTo[epssigma,{x,y,Sqrt[((delta2[[i,j]])/(npoints[[i,j]]))-(((((delta1[[i,j]])/(npoints[[i,j]]))))^2)]}];

];
];
];

ListPlot3D[eps0,PlotRange->All,AxesStyle->18]
ListPlot3D[eps1,PlotRange->All,AxesStyle->18]
ListPlot3D[eps2,PlotRange->All,AxesStyle->18]
prms=ListPlot3D[epssigma,PlotRange->All,AxesStyle->18,PlotStyle->Green]

meanxf= meanx;
eps2f=eps2;

(* Execute the code in y5m2012_7b.nb before these two blocks of code. And do not execute the code above in h123 anymore. *)

eps2slice=Table[{},{dim}];
For[slice=1,slice≤Length[meanx],slice++,
For[i=1,i≤Length[eps2],i++,
If[eps2[[i,1]]>0||eps2[[i,2]]>0,Continue[]];
If[eps2[[i,1]]==meanx[[slice]],
AppendTo[eps2slice[[slice]],{eps2[[i,2]],eps2[[i,3]]}];
];
];
]

eps2diag={};
For[slice=1,slice≤Length[meanx],slice++,
For[i=1,i≤Length[eps2],i++,
If[eps2[[i,1]]>0||eps2[[i,2]]>0,Continue[]];
If[eps2[[i,1]]==meanx[[slice]]&&eps2[[i,2]]==meanx[[slice]],
AppendTo[eps2diag,{eps2[[i,2]],eps2[[i,3]]}];
];
];
]

eps2fslice=Table[{},{dim}];
For[slice=1,slice≤Length[meanxf],slice++,
For[i=1,i≤Length[eps2f],i++,
If[eps2f[[i,1]]>0||eps2f[[i,2]]>0,Continue[]];
If[eps2f[[i,1]]==meanxf[[slice]],
AppendTo[eps2fslice[[slice]],{eps2f[[i,2]],eps2f[[i,3]]}];
];
];
]

eps2fdiag={};
For[slice=1,slice≤Length[meanx],slice++,
For[i=1,i≤Length[eps2f],i++,
If[eps2f[[i,1]]>0||eps2f[[i,2]]>0,Continue[]];
If[eps2f[[i,1]]==meanxf[[slice]]&&eps2f[[i,2]]==meanxf[[slice]],
AppendTo[eps2fdiag,{eps2f[[i,2]],eps2f[[i,3]]}];
];
];
]

(* Plot raw data and noise *)

scale=Plot[0,{x,0,1.5},PlotRange->{0,0.21},AxesStyle->18,Ticks->{{0,0.5,1.0,1.5},{0,0.03,0.06,0.09,0.12,0.15,0.18,0.21}}];

size=0.02;
p11=ListPlot[Abs[eps2slice[[1]]],PlotStyle->Directive[PointSize[size],Red]];
p12=ListPlot[Abs[eps2slice[[2]]],PlotStyle->Directive[PointSize[size],Red]];
p13=ListPlot[Abs[eps2slice[[3]]],PlotStyle->Directive[PointSize[size],Yellow]];
p14=ListPlot[Abs[eps2slice[[4]]],PlotStyle->Directive[PointSize[size],Green]];
p15=ListPlot[Abs[eps2slice[[5]]],PlotStyle->Directive[PointSize[size],Blue]];
p16=ListPlot[Abs[eps2slice[[6]]],PlotStyle->Directive[PointSize[size],Purple]];
p17=ListPlot[Abs[eps2slice[[7]]],PlotStyle->Directive[PointSize[size],Gray]];
p18=ListPlot[Abs[eps2slice[[8]]],PlotStyle->Directive[PointSize[size],Black]];
p110=ListPlot[Abs[eps2slice[[10]]],PlotStyle->Directive[PointSize[size],Red]];
Show[(*p11,*)p12,p13,p14,p15,p16,p17,p18,p110]

size=0.02;
p21=ListPlot[Abs[eps2fslice[[1]]],PlotStyle->Directive[PointSize[size],Red],PlotMarkers->{"*",30}];
p22=ListPlot[Abs[eps2fslice[[2]]],PlotStyle->Directive[PointSize[size],Red],PlotMarkers->{"*",30}];
p23=ListPlot[Abs[eps2fslice[[3]]],PlotStyle->Directive[PointSize[size],Yellow],PlotMarkers->{"*",30}];
p24=ListPlot[Abs[eps2fslice[[4]]],PlotStyle->Directive[PointSize[size],Green],PlotMarkers->{"*",30}];
p25=ListPlot[Abs[eps2fslice[[5]]],PlotStyle->Directive[PointSize[size],Blue],PlotMarkers->{"*",30}];
p26=ListPlot[Abs[eps2fslice[[6]]],PlotStyle->Directive[PointSize[size],Purple],PlotMarkers->{"*",30}];
p27=ListPlot[Abs[eps2fslice[[7]]],PlotStyle->Directive[PointSize[size],Gray],PlotMarkers->{"*",30}];
p28=ListPlot[Abs[eps2fslice[[8]]],PlotStyle->Directive[PointSize[size],Black],PlotMarkers->{"*",30}];
p210=ListPlot[Abs[eps2fslice[[10]]],PlotStyle->Directive[PointSize[size],Red],PlotMarkers->{"*",30}];
Show[scale,(*p21,*)p22,p23,p24,p25,p26,p27,p28,p210]

Show[scale,p11,p21]
Show[scale,p12,p22]
Show[scale,p13,p23]
Show[scale,p14,p24]
Show[scale,p15,p25]
Show[scale,p16,p26]
Show[scale,p17,p27]
Show[scale,p18,p28]
Show[scale,p110,p210]
Show[scale,p12,p22,p18,p28,AspectRatio->1]

(* Plot subtracted data : variance *)

size=0.03;
scale=Plot[0,{x,0,1.5},PlotRange->{-0.01,0.1}];
(*p31=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[1]]][[1]],Transpose[eps2slice[[1]]][[1]]}]],Transpose[eps2slice[[1]]][[2]]-Transpose[eps2fslice[[1]]][[2]]}],PlotStyle->Directive[PointSize[size],Red]];*)
p32=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[2]]][[1]],Transpose[eps2slice[[2]]][[1]]}]],Transpose[eps2slice[[2]]][[2]]-Transpose[eps2fslice[[2]]][[2]]}],PlotStyle->Directive[PointSize[size],Red]];
p33=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[3]]][[1]],Transpose[eps2slice[[3]]][[1]]}]],Transpose[eps2slice[[3]]][[2]]-Transpose[eps2fslice[[3]]][[2]]}],PlotStyle->Directive[PointSize[size],RGBColor[1.0,0.85,0.0]]];
p34=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[4]]][[1]],Transpose[eps2slice[[4]]][[1]]}]],Transpose[eps2slice[[4]]][[2]]-Transpose[eps2fslice[[4]]][[2]]}],PlotStyle->Directive[PointSize[size],Green]];
p35=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[5]]][[1]],Transpose[eps2slice[[5]]][[1]]}]],Transpose[eps2slice[[5]]][[2]]-Transpose[eps2fslice[[5]]][[2]]}],PlotStyle->Directive[PointSize[size],Blue]];
p36=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[6]]][[1]],Transpose[eps2slice[[6]]][[1]]}]],Transpose[eps2slice[[6]]][[2]]-Transpose[eps2fslice[[6]]][[2]]}],PlotStyle->Directive[PointSize[size],Purple]];
p37=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[7]]][[1]],Transpose[eps2slice[[7]]][[1]]}]],Transpose[eps2slice[[7]]][[2]]-Transpose[eps2fslice[[7]]][[2]]}],PlotStyle->Directive[PointSize[size],Gray]];
p38=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[8]]][[1]],Transpose[eps2slice[[8]]][[1]]}]],Transpose[eps2slice[[8]]][[2]]-Transpose[eps2fslice[[8]]][[2]]}],PlotStyle->Directive[PointSize[size],Black]];
Show[scale,(*p31,*)p32,p33,p34,p35,p36,p37,p38]


(*p41=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[1]]][[1]],Transpose[eps2slice[[1]]][[1]]}]],Transpose[eps2slice[[1]]][[2]]-Transpose[eps2fslice[[1]]][[2]]}],PlotStyle->Directive[PointSize[size],Dashed,Red]];*)
p42=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[2]]][[1]],Transpose[eps2slice[[2]]][[1]]}]],Transpose[eps2slice[[2]]][[2]]-Transpose[eps2fslice[[2]]][[2]]}],PlotStyle->Directive[PointSize[size],Dashed,Red],PlotMarkers->"●"];
p43=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[3]]][[1]],Transpose[eps2slice[[3]]][[1]]}]],Transpose[eps2slice[[3]]][[2]]-Transpose[eps2fslice[[3]]][[2]]}],PlotStyle->Directive[PointSize[size],Dashed,RGBColor[1.0,0.85,0.0]],PlotMarkers->"●"];
p44=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[4]]][[1]],Transpose[eps2slice[[4]]][[1]]}]],Transpose[eps2slice[[4]]][[2]]-Transpose[eps2fslice[[4]]][[2]]}],PlotStyle->Directive[PointSize[size],Dashed,Green],PlotMarkers->"●"];
p45=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[5]]][[1]],Transpose[eps2slice[[5]]][[1]]}]],Transpose[eps2slice[[5]]][[2]]-Transpose[eps2fslice[[5]]][[2]]}],PlotStyle->Directive[PointSize[size],Dashed,Blue],PlotMarkers->"●"];
p46=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[6]]][[1]],Transpose[eps2slice[[6]]][[1]]}]],Transpose[eps2slice[[6]]][[2]]-Transpose[eps2fslice[[6]]][[2]]}],PlotStyle->Directive[PointSize[size],Dashed,Purple],PlotMarkers->"●"];
p47=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[7]]][[1]],Transpose[eps2slice[[7]]][[1]]}]],Transpose[eps2slice[[7]]][[2]]-Transpose[eps2fslice[[7]]][[2]]}],PlotStyle->Directive[PointSize[size],Dashed,Gray],PlotMarkers->"●"];
p48=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[8]]][[1]],Transpose[eps2slice[[8]]][[1]]}]],Transpose[eps2slice[[8]]][[2]]-Transpose[eps2fslice[[8]]][[2]]}],PlotStyle->Directive[PointSize[size],Dashed,Black],PlotMarkers->"●"];
Show[scale,(*p41,*)p42,p43,p44,p45,p46,p47,p48]

(* Execute this *)

Clear[y]
ys=Abs[Mean[{Transpose[eps2fslice[[8]]][[1]],Transpose[eps2slice[[8]]][[1]]}]]

(* Random walk fit *)

p51=Plot[0.0693(2((x y)/(x+y)))/.y->ys[[1]],{x,0,1.5},PlotStyle->Directive[Red],PlotRange->{{0,1.5},{0,0.09}}];
p52=Plot[0.0693(2((x y)/(x+y)))/.y->ys[[2]],{x,0,1.5},PlotStyle->Directive[Red],PlotRange->{{0,1.5},{0,0.1}}];
p53=Plot[0.0693(2((x y)/(x+y)))/.y->ys[[3]],{x,0,1.5},PlotStyle->Directive[RGBColor[1.0,0.85,0.0]],PlotRange->{{0,1.5},{0,0.08}}];
p54=Plot[0.0693(2((x y)/(x+y)))/.y->ys[[4]],{x,0,1.5},PlotStyle->Directive[Green],PlotRange->{{0,1.5},{0,0.08}}];
p55=Plot[0.0693(2((x y)/(x+y)))/.y->ys[[5]],{x,0,1.5},PlotStyle->Directive[Blue],PlotRange->{{0,1.5},{0,0.08}}];
p56=Plot[0.0693(2((x y)/(x+y)))/.y->ys[[6]],{x,0,1.5},PlotStyle->Directive[Purple],PlotRange->{{0,1.5},{0,0.08}}];
p57=Plot[0.0693(2((x y)/(x+y)))/.y->ys[[7]],{x,0,1.5},PlotStyle->Directive[Gray],PlotRange->{{0,1.5},{0,0.08}}];
p58=Plot[0.0693(2((x y)/(x+y)))/.y->ys[[8]],{x,0,1.5},PlotStyle->Directive[Black],PlotRange->{{0,1.5},{0,0.08}}];
Show[scale,(*p51,*)p52,p53,p54,p55,p56,p57,p58,(*p41,*)p42,p43,p44,p45,p46,p47,p48,(* p31,*)p32,p33,p34,p35,p36,p37,p38,AxesStyle->18,Ticks->{{0,0.5,1.0,1.5},{0.03,0.06,0.09}},AspectRatio->1]
Show[scale,p52,p54,p56,p58,p42,p44,p46,p48,p32,p34,p36,p38,AxesStyle->18,Ticks->{{0,0.5,1.0,1.5},{0.03,0.06,0.09}},AspectRatio->1]

(* FourthRoot fit *)

p61=Plot[0.0628Power[Abs[x]Abs[y],0.5]/.y->ys[[1]],{x,0,1.5},PlotStyle->Directive[Red],PlotRange->{{0,1.5},{0,0.1}}];
p62=Plot[0.0628Power[Abs[x]Abs[y],0.5]/.y->ys[[2]],{x,0,1.5},PlotStyle->Directive[Red],PlotRange->{{0,1.5},{0,0.1}}];
p63=Plot[0.0628Power[Abs[x]Abs[y],0.5]/.y->ys[[3]],{x,0,1.5},PlotStyle->Directive[RGBColor[1.0,0.85,0.0]],PlotRange->{{0,1.5},{0,0.08}}];
p64=Plot[0.0628Power[Abs[x]Abs[y],0.5]/.y->ys[[4]],{x,0,1.5},PlotStyle->Directive[Green],PlotRange->{{0,1.5},{0,0.08}}];
p65=Plot[0.0628Power[Abs[x]Abs[y],0.5]/.y->ys[[5]],{x,0,1.5},PlotStyle->Directive[Blue],PlotRange->{{0,1.5},{0,0.08}}];
p66=Plot[0.0628Power[Abs[x]Abs[y],0.5]/.y->ys[[6]],{x,0,1.5},PlotStyle->Directive[Purple],PlotRange->{{0,1.5},{0,0.08}}];
p67=Plot[0.0628Power[Abs[x]Abs[y],0.5]/.y->ys[[7]],{x,0,1.5},PlotStyle->Directive[Gray],PlotRange->{{0,1.5},{0,0.08}}];
p68=Plot[0.0628Power[Abs[x]Abs[y],0.5]/.y->ys[[8]],{x,0,1.5},PlotStyle->Directive[Black],PlotRange->{{0,1.5},{0,0.08}}];
Show[scale,(*p61,*)p62,p63,p64,p65,p66,p67,p68,(*p41,*)p42,p43,p44,p45,p46,p47,p48,(* p31,*)p32,p33,p34,p35,p36,p37,p38,AxesStyle->18,Ticks->{{0,0.5,1.0,1.5},{0.03,0.06,0.09}},AspectRatio->1]
Show[scale,p62,p64,p66,p68,p42,p44,p46,p48,p32,p34,p36,p38,AxesStyle->18,Ticks->{{0,0.5,1.0,1.5},{0.03,0.06,0.09}},AspectRatio->1]

eps2=DeleteCases[eps2,{x_,y_,z_}/;x<-2];
eps2=DeleteCases[eps2,{x_,y_,z_}/;y<-2];
Length[eps2]

eps2f=DeleteCases[eps2f,{x_,y_,z_}/;x<-2];
eps2f=DeleteCases[eps2f,{x_,y_,z_}/;y<-2];
Length[eps2f]

(* Variance *)

eps2diff={};
xs={};
counter=0;
For[i=1,i≤Length[eps2],i++,
avgx=Mean[{eps2[[i,1]],eps2f[[i,1]]}];
avgy=Mean[{eps2[[i,2]],eps2f[[i,2]]}];
AppendTo[xs,avgx];
AppendTo[xs,avgy];
If[avgx>-2&&avgx<0&&avgy>-2&&avgy<0&&eps2[[i,3]]-eps2f[[i,3]]<0,   (* only deleterious and not the very last row *)Print[counter++,"  ",eps2[[i,3]],"  ",eps2f[[i,3]],"  ",eps2[[i,3]]-eps2f[[i,3]]]];
diff=eps2[[i,3]]-eps2f[[i,3]];
AppendTo[eps2diff,{avgx,avgy,diff}];
]

xs=Union[xs]
Length[xs]

slices={};
For[i=1,i≤Length[xs],i++,
lista={};
For[j=1,j≤Length[eps2diff],j++,
If[eps2diff[[j,1]]==xs[[i]],
AppendTo[lista,eps2diff[[j]]];
];
];
AppendTo[slices,lista];
]

Length[slices]

slices={Take[slices,{2}],Take[slices,{3}],Take[slices,{4}],Take[slices,{5}],Take[slices,{6}],Take[slices,{7}],Take[slices,{9}]};
slices=Flatten[slices,1];

size=0.04;
surf8=ListPointPlot3D[slices,PlotStyle->{Directive[Gray,PointSize[size]]},PlotRange->{{-1,0},{-1,0},{0,0.07}},Ticks->{{0,-0.5,-1.0,-1.5},{0,-0.5,-1.0,-1.5},{0,0.02,0.04,0.06},{0,-0.5,-1.0,-1.5},{0,-0.5,-1.0,-1.5},{0,0.02,0.04,0.06}},AxesStyle->18];

surf=Plot3D[((*0.0693*)0.0828 2((Abs[x]Abs[y])/(Abs[x]+Abs[y]))),{x,-1,0},{y,-1,0},LabelStyle->18,ClippingStyle->None,PlotRange->{0,0.11},PlotStyle->Directive[White,Opacity[0.5]],Mesh->4,MaxRecursion->6,MeshStyle->Directive[White],AspectRatio->1];

Show[surf8,surf,BoxStyle->Directive[Black,Thick],AxesEdge->{{1,-1},{1,-1},{1,-1}},TicksStyle->Thick,ViewPoint->{2,1,0.5},BoxRatios->{1,1,0.5}]

Show[,]

Export[StringJoin[path,"FinalFIGS/5a.pdf"],,ImageResolution->600]

(* Plot subtracted data : standard deviation *)

size=0.03;
scale=Plot[0,{x,0,1.5},PlotRange->{-0.01,0.3}];
(*p31=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[1]]][[1]],Transpose[eps2slice[[1]]][[1]]}]],Sqrt[Transpose[eps2slice[[1]]][[2]]-Transpose[eps2fslice[[1]]][[2]]]}],PlotStyle->Directive[PointSize[size],Red]];*)
p32=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[2]]][[1]],Transpose[eps2slice[[2]]][[1]]}]],Sqrt[Transpose[eps2slice[[2]]][[2]]-Transpose[eps2fslice[[2]]][[2]]]}],PlotStyle->Directive[PointSize[size],Red]];
p33=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[3]]][[1]],Transpose[eps2slice[[3]]][[1]]}]],Sqrt[Transpose[eps2slice[[3]]][[2]]-Transpose[eps2fslice[[3]]][[2]]]}],PlotStyle->Directive[PointSize[size],RGBColor[1.0,0.85,0.0]]];
p34=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[4]]][[1]],Transpose[eps2slice[[4]]][[1]]}]],Sqrt[Transpose[eps2slice[[4]]][[2]]-Transpose[eps2fslice[[4]]][[2]]]}],PlotStyle->Directive[PointSize[size],Green]];
p35=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[5]]][[1]],Transpose[eps2slice[[5]]][[1]]}]],Sqrt[Transpose[eps2slice[[5]]][[2]]-Transpose[eps2fslice[[5]]][[2]]]}],PlotStyle->Directive[PointSize[size],Blue]];
p36=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[6]]][[1]],Transpose[eps2slice[[6]]][[1]]}]],Sqrt[Transpose[eps2slice[[6]]][[2]]-Transpose[eps2fslice[[6]]][[2]]]}],PlotStyle->Directive[PointSize[size],Purple]];
p37=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[7]]][[1]],Transpose[eps2slice[[7]]][[1]]}]],Sqrt[Transpose[eps2slice[[7]]][[2]]-Transpose[eps2fslice[[7]]][[2]]]}],PlotStyle->Directive[PointSize[size],Gray]];
p38=ListPlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[8]]][[1]],Transpose[eps2slice[[8]]][[1]]}]],Sqrt[Transpose[eps2slice[[8]]][[2]]-Transpose[eps2fslice[[8]]][[2]]]}],PlotStyle->Directive[PointSize[size],Black]];
Show[scale,(*p31,*)p32,p33,p34,p35,p36,p37,p38]


(*p41=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[1]]][[1]],Transpose[eps2slice[[1]]][[1]]}]],Sqrt[Transpose[eps2slice[[1]]][[2]]-Transpose[eps2fslice[[1]]][[2]]}],PlotStyle->Directive[PointSize[size],Dashed,Red]];*)
p42=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[2]]][[1]],Transpose[eps2slice[[2]]][[1]]}]],Sqrt[Transpose[eps2slice[[2]]][[2]]-Transpose[eps2fslice[[2]]][[2]]]}],PlotStyle->Directive[PointSize[size],Dashed,Red],PlotMarkers->"●"];
p43=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[3]]][[1]],Transpose[eps2slice[[3]]][[1]]}]],Sqrt[Transpose[eps2slice[[3]]][[2]]-Transpose[eps2fslice[[3]]][[2]]]}],PlotStyle->Directive[PointSize[size],Dashed,RGBColor[1.0,0.85,0.0]],PlotMarkers->"●"];
p44=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[4]]][[1]],Transpose[eps2slice[[4]]][[1]]}]],Sqrt[Transpose[eps2slice[[4]]][[2]]-Transpose[eps2fslice[[4]]][[2]]]}],PlotStyle->Directive[PointSize[size],Dashed,Green],PlotMarkers->"●"];
p45=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[5]]][[1]],Transpose[eps2slice[[5]]][[1]]}]],Sqrt[Transpose[eps2slice[[5]]][[2]]-Transpose[eps2fslice[[5]]][[2]]]}],PlotStyle->Directive[PointSize[size],Dashed,Blue],PlotMarkers->"●"];
p46=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[6]]][[1]],Transpose[eps2slice[[6]]][[1]]}]],Sqrt[Transpose[eps2slice[[6]]][[2]]-Transpose[eps2fslice[[6]]][[2]]]}],PlotStyle->Directive[PointSize[size],Dashed,Purple],PlotMarkers->"●"];
p47=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[7]]][[1]],Transpose[eps2slice[[7]]][[1]]}]],Sqrt[Transpose[eps2slice[[7]]][[2]]-Transpose[eps2fslice[[7]]][[2]]]}],PlotStyle->Directive[PointSize[size],Dashed,Gray],PlotMarkers->"●"];
p48=ListLinePlot[Transpose[{Abs[Mean[{Transpose[eps2fslice[[8]]][[1]],Transpose[eps2slice[[8]]][[1]]}]],Sqrt[Transpose[eps2slice[[8]]][[2]]-Transpose[eps2fslice[[8]]][[2]]]}],PlotStyle->Directive[PointSize[size],Dashed,Black],PlotMarkers->"●"];
Show[scale,(*p41,*)p42,p43,p44,p45,p46,p47,p48]

(* Execute this *)

Clear[y]
ys=Abs[Mean[{Transpose[eps2fslice[[8]]][[1]],Transpose[eps2slice[[8]]][[1]]}]]

(* Random walk fit *)

p51=Plot[0.374Sqrt[((x y)/(x+y))]/.y->ys[[1]],{x,0,1.5},PlotStyle->Directive[Red],PlotRange->{{0,1.5},{0,0.3}}];
p52=Plot[0.374Sqrt[((x y)/(x+y))]/.y->ys[[2]],{x,0,1.5},PlotStyle->Directive[Red],PlotRange->{{0,1.5},{0,0.3}}];
p53=Plot[0.374Sqrt[((x y)/(x+y))]/.y->ys[[3]],{x,0,1.5},PlotStyle->Directive[RGBColor[1.0,0.85,0.0]],PlotRange->{{0,1.5},{0,0.3}}];
p54=Plot[0.374Sqrt[((x y)/(x+y))]/.y->ys[[4]],{x,0,1.5},PlotStyle->Directive[Green],PlotRange->{{0,1.5},{0,0.3}}];
p55=Plot[0.374Sqrt[((x y)/(x+y))]/.y->ys[[5]],{x,0,1.5},PlotStyle->Directive[Blue],PlotRange->{{0,1.5},{0,0.3}}];
p56=Plot[0.374Sqrt[((x y)/(x+y))]/.y->ys[[6]],{x,0,1.5},PlotStyle->Directive[Purple],PlotRange->{{0,1.5},{0,0.3}}];
p57=Plot[0.374Sqrt[((x y)/(x+y))]/.y->ys[[7]],{x,0,1.5},PlotStyle->Directive[Gray],PlotRange->{{0,1.5},{0,0.3}}];
p58=Plot[0.374Sqrt[((x y)/(x+y))]/.y->ys[[8]],{x,0,1.5},PlotStyle->Directive[Black],PlotRange->{{0,1.5},{0,0.3}}];
Show[scale,(*p51,*)p52,p53,p54,p55,p56,p57,p58,(*p41,*)p42,p43,p44,p45,p46,p47,p48,(* p31,*)p32,p33,p34,p35,p36,p37,p38,AxesStyle->18,Ticks->{{0,0.5,1.0,1.5},{0.1,0.2,0.3}},AspectRatio->1]
Show[scale,p52,p54,p56,p58,p42,p44,p46,p48,p32,p34,p36,p38,AxesStyle->18,Ticks->{{0,0.5,1.0,1.5},{0.1,0.2,0.3}},AspectRatio->1]

(* Here I consider the sigma(eps) relative to the combination of two deleterious knockouts only.                *)
(* I assume sigma(eps) = c (Sqrt[((df1 df2)/(df1 + df2))]) and I estimate the best value for c by minimizing square deviations       *)
(* (second column). I also report the mean relative error (third column) and the largest error (fourth column). *)

epssigma=eps2diff;

For[c=0.075,c≤0.079,c+=0.0001,
total={};
relativeerr1={};
relativeerr2={};
For[i=1,i≤Length[epssigma],i++,
If[epssigma[[i,1]]==xs[[1]]||epssigma[[i,2]]==xs[[1]],Continue[]];
If[epssigma[[i,3]]≠"Null"&&epssigma[[i,1]]<0&&epssigma[[i,2]]≤epssigma[[i,1]],   (* consider only j≤i *)
AppendTo[total,c ((2Abs[epssigma[[i,1]]] Abs[epssigma[[i,2]]])/(Abs[epssigma[[i,1]]] + Abs[epssigma[[i,2]]]))-epssigma[[i,3]]];
AppendTo[relativeerr1,((c ((2Abs[epssigma[[i,1]]] Abs[epssigma[[i,2]]])/(Abs[epssigma[[i,1]]] + Abs[epssigma[[i,2]]]))-epssigma[[i,3]])/(c ((2Abs[epssigma[[i,1]]] Abs[epssigma[[i,2]]])/(Abs[epssigma[[i,1]]] + Abs[epssigma[[i,2]]]))))];
AppendTo[relativeerr2,((c ((2Abs[epssigma[[i,1]]] Abs[epssigma[[i,2]]])/(Abs[epssigma[[i,1]]] + Abs[epssigma[[i,2]]]))-epssigma[[i,3]])/(epssigma[[i,3]]))];
];
];
Print[c,"  ",Norm[total],"    ",Mean[Abs[relativeerr1]],"  ",Max[Abs[relativeerr1]],"    ",Mean[Abs[relativeerr2]],"  ",Max[Abs[relativeerr2]]];
]

(* Diagonal *)

pdiag=ListPlot[Abs[eps2diag],PlotStyle->PointSize[size]];
pdiagf=ListPlot[Abs[eps2fdiag],PlotMarkers->{"*",30}];
Show[pdiag,pdiagf]

lst={};
For[i=1,i≤9,i++,
AppendTo[lst,{Abs[eps2diag[[i,1]]],eps2diag[[i,2]]-eps2fdiag[[i+1,2]]}];
]

pdiagdiff=ListPlot[lst,PlotStyle->PointSize[size],PlotRange->All];
fitted=Plot[0.06959237936683386`x,{x,0,1.3}];
Show[pdiagdiff,fitted]

Clear[x]
Fit[lst,x,x]

epssigmadiff={};
For[i=1,i≤Length[eps2],i++,
avgx=Mean[{eps2[[i,1]],eps2f[[i,1]]}];
avgy=Mean[{eps2[[i,2]],eps2f[[i,2]]}];
diff=Sqrt[Max[0,eps2[[i,3]]-eps2f[[i,3]]]];
AppendTo[epssigmadiff,{avgx,avgy,diff}];
]
p0=ListPlot3D[epssigmadiff]

p2=Plot3D[Sqrt[0.0628]Power[x y,0.25],{x,-2,0},{y,-2,0},PlotStyle->Blue];
Show[p0,p2]

p1=Plot3D[Sqrt[-0.078 2((x y)/(x+y))],{x,-2.5,0},{y,-2.5,0},PlotStyle->Red];
Show[p0,p1]

p1=Plot3D[Sqrt[-0.078 2((x y)/(x+y))],{x,-1.0,0},{y,-1.0,0},PlotStyle->Red];
Show[p1,p0]

(* ALL IN ONE STEP *)

pow=0.25;
threshold=1.20;
wrong=0;

(* Diagonal slices raw data *)

diag=Table[0,{250000}];
index=1;

(* Group D *)
singlekor=Import[StringJoin[path,"FILES2012/a_tsq.dat"]];
singlekoc=Import[StringJoin[path,"FILES2012/a_genuinearray.dat"]];
If[wrong==0,
eps=Import[StringJoin[path,"FILES2012/c_epsD.dat"]],
eps=Import[StringJoin[path,"FILES2012/c_epsD_wrongdef.dat"]];
];

For[i=1,i≤Length[singlekor],i++,
fi=Log[2,singlekor[[i,2]]];
For[j=1,j≤Length[singlekoc],j++,
fj=Log[2,singlekoc[[j,2]]];

If[fj≠0,
If[fi≠0,
r=(fi/fj),
r=1;
];
];

If[(r≥1&&r≤threshold)||((r^(-1))≥1&&(r^(-1))≤threshold),
If[eps[[i,j]]≠"NaN",
diag[[index]]={Mean[{fi,fj}],eps[[i,j]]};
index++;
];
];

];
If[Mod[i,100]==1,Print[i]];
]

index
diag=DeleteCases[diag,0];
Length[diag]


(* DELETERIOUS MUTATIONS *)

uplist={};
midlist={};
lowlist={};
count={};

(*For[mid=-0.1,mid≥Log[2,0.25],mid=mid-0.2,                                          (* linear binning *)*)
For[mid=Log[2,0.995],mid≥Log[2,0.25],mid=Power[2,pow]mid,             (* exponential binning *)

lower=0.5 mid(1+Power[2,-pow]);
upper=0.5 mid(1+Power[2,pow]);
(*lower=mid+0.1;
upper=mid-0.1;*)
distro={};

For[i=1,i≤Length[diag],i++,
If[diag[[i,1]]<upper||diag[[i,1]]>lower,Continue[]];
AppendTo[distro,diag[[i,2]]];
];


If[Length[distro]≥2,

(* begin bootstrap *)
bsvar={};
For[j=1,j≤1000,j++,
bsdistro=RandomChoice[distro,Length[distro]];
AppendTo[bsvar,Variance[bsdistro](*+((Mean[distro])^2)*)];
];
(* end bootstrap *)

AppendTo[uplist,{mid,Quantile[bsvar,(3/4)]}];
AppendTo[midlist,{mid,Variance[distro](*+((Mean[distro])^2)*)}];
AppendTo[lowlist,{mid,Quantile[bsvar,(1/4)]}];
AppendTo[count,{mid,Length[distro]}];

If[mid>-0.1&&((StandardDeviation[distro])^2)>0.01,
Print["z  ",((StandardDeviation[distro])^2),Take[Sort[distro],20]];
];
];

Print[mid]

]

uplistdel=uplist;
midlistdel=midlist;
lowlistdel=lowlist;


(* BENEFICIAL MUTATIONS *)

uplist={};
midlist={};
lowlist={};
count={};

(*For[mid=Log[2,0.999],mid≥Log[2,0.25],mid=mid-0.05,                                          (* linear binning *)*)
For[mid=Log[2,1.01],mid≤Log[2,1.35],mid=Power[2,pow]mid,             (* exponential binning *)

lower=0.5 mid(1+Power[2,-pow]);
upper=0.5 mid(1+Power[2,pow]);
distro={};

For[i=1,i≤Length[diag],i++,
If[diag[[i,1]]>upper||diag[[i,1]]<lower,Continue[]];
AppendTo[distro,diag[[i,2]]];
];


If[Length[distro]≥2,

(* begin bootstrap *)
bsvar={};
For[j=1,j≤10,j++,
bsdistro=RandomChoice[distro,Length[distro]];
AppendTo[bsvar,Variance[bsdistro](*+((Mean[distro])^2)*)];
];
(* end bootstrap *)

AppendTo[uplist,{mid,Quantile[bsvar,(3/4)]}];
AppendTo[midlist,{mid,Variance[distro](*+((Mean[distro])^2)*)}];
AppendTo[lowlist,{mid,Quantile[bsvar,(1/4)]}];
AppendTo[count,{mid,Length[distro]}];

If[mid>-0.1&&((StandardDeviation[distro])^2)>0.01,
Print["z  ",((StandardDeviation[distro])^2),Take[Sort[distro],20]];
];
];

Print[mid]

]

uplistben=uplist;
midlistben=midlist;
lowlistben=lowlist;

(* NOISE *)

(* Diagonal slices experimental noise *)

diag=Table[0,{2500000}];
index=1;

(* Group D1 *)
singlekor=Import[StringJoin[path,"FILES2012/h1a_tsq_fake_studentt.dat"]];
singlekoc=Import[StringJoin[path,"FILES2012/h1a_genuinearray_fake_studentt.dat"]];
If[wrong==0,
eps=Import[StringJoin[path,"FILES2012/j1c_epsD_fake_studentt.dat"]],
eps=Import[StringJoin[path,"FILES2012/j1c_epsD_fake_studentt_wrongdef.dat"]];
];

For[i=1,i≤Length[singlekor],i++,
fi=Log[2,singlekor[[i,2]]];
For[j=1,j≤Length[singlekoc],j++,
fj=Log[2,singlekoc[[j,2]]];

If[fj≠0,
If[fi≠0,
r=(fi/fj),
r=1;
];
];

If[(r≥1&&r≤threshold)||((r^(-1))≥1&&(r^(-1))≤threshold),
If[eps[[i,j]]≠"NaN",
diag[[index]]={Mean[{fi,fj}],eps[[i,j]]};
index++;
];
];

];
]

(*******************************************************)

(* Group D2 *)
singlekor=Import[StringJoin[path,"FILES2012/h2a_tsq_fake_studentt.dat"]];
singlekoc=Import[StringJoin[path,"FILES2012/h2a_genuinearray_fake_studentt.dat"]];
If[wrong==0,
eps=Import[StringJoin[path,"FILES2012/j2c_epsD_fake_studentt.dat"]],
eps=Import[StringJoin[path,"FILES2012/j2c_epsD_fake_studentt_wrongdef.dat"]];
];

For[i=1,i≤Length[singlekor],i++,
fi=Log[2,singlekor[[i,2]]];
For[j=1,j≤Length[singlekoc],j++,
fj=Log[2,singlekoc[[j,2]]];

If[fj≠0,
If[fi≠0,
r=(fi/fj),
r=1;
];
];

If[(r≥1&&r≤threshold)||((r^(-1))≥1&&(r^(-1))≤threshold),
If[eps[[i,j]]≠"NaN",
diag[[index]]={Mean[{fi,fj}],eps[[i,j]]};
index++;
];
];

];
]

(*******************************************************)

(* Group D3 *)
singlekor=Import[StringJoin[path,"FILES2012/h3a_tsq_fake_studentt.dat"]];
singlekoc=Import[StringJoin[path,"FILES2012/h3a_genuinearray_fake_studentt.dat"]];
If[wrong==0,
eps=Import[StringJoin[path,"FILES2012/j3c_epsD_fake_studentt.dat"]],
eps=Import[StringJoin[path,"FILES2012/j3c_epsD_fake_studentt_wrongdef.dat"]];
];

For[i=1,i≤Length[singlekor],i++,
fi=Log[2,singlekor[[i,2]]];
For[j=1,j≤Length[singlekoc],j++,
fj=Log[2,singlekoc[[j,2]]];

If[fj≠0,
If[fi≠0,
r=(fi/fj),
r=1;
];
];

If[(r≥1&&r≤threshold)||((r^(-1))≥1&&(r^(-1))≤threshold),
If[eps[[i,j]]≠"NaN",
diag[[index]]={Mean[{fi,fj}],eps[[i,j]]};
index++;
];
];

];
]

(*******************************************************)

(* Group D4 *)
singlekor=Import[StringJoin[path,"FILES2012/h4a_tsq_fake_studentt.dat"]];
singlekoc=Import[StringJoin[path,"FILES2012/h4a_genuinearray_fake_studentt.dat"]];
If[wrong==0,
eps=Import[StringJoin[path,"FILES2012/j4c_epsD_fake_studentt.dat"]],
eps=Import[StringJoin[path,"FILES2012/j4c_epsD_fake_studentt_wrongdef.dat"]];
];

For[i=1,i≤Length[singlekor],i++,
fi=Log[2,singlekor[[i,2]]];
For[j=1,j≤Length[singlekoc],j++,
fj=Log[2,singlekoc[[j,2]]];

If[fj≠0,
If[fi≠0,
r=(fi/fj),
r=1;
];
];

If[(r≥1&&r≤threshold)||((r^(-1))≥1&&(r^(-1))≤threshold),
If[eps[[i,j]]≠"NaN",
diag[[index]]={Mean[{fi,fj}],eps[[i,j]]};
index++;
];
];

];
]

(*******************************************************)

(* Group D5 *)
singlekor=Import[StringJoin[path,"FILES2012/h5a_tsq_fake_studentt.dat"]];
singlekoc=Import[StringJoin[path,"FILES2012/h5a_genuinearray_fake_studentt.dat"]];
If[wrong==0,
eps=Import[StringJoin[path,"FILES2012/j5c_epsD_fake_studentt.dat"]],
eps=Import[StringJoin[path,"FILES2012/j5c_epsD_fake_studentt_wrongdef.dat"]];
];

For[i=1,i≤Length[singlekor],i++,
fi=Log[2,singlekor[[i,2]]];
For[j=1,j≤Length[singlekoc],j++,
fj=Log[2,singlekoc[[j,2]]];

If[fj≠0,
If[fi≠0,
r=(fi/fj),
r=1;
];
];

If[(r≥1&&r≤threshold)||((r^(-1))≥1&&(r^(-1))≤threshold),
If[eps[[i,j]]≠"NaN",
diag[[index]]={Mean[{fi,fj}],eps[[i,j]]};
index++;
];
];

];
]

(*******************************************************)

(* Group D6 *)
singlekor=Import[StringJoin[path,"FILES2012/h6a_tsq_fake_studentt.dat"]];
singlekoc=Import[StringJoin[path,"FILES2012/h6a_genuinearray_fake_studentt.dat"]];
If[wrong==0,
eps=Import[StringJoin[path,"FILES2012/j6c_epsD_fake_studentt.dat"]],
eps=Import[StringJoin[path,"FILES2012/j6c_epsD_fake_studentt_wrongdef.dat"]];
];

For[i=1,i≤Length[singlekor],i++,
fi=Log[2,singlekor[[i,2]]];
For[j=1,j≤Length[singlekoc],j++,
fj=Log[2,singlekoc[[j,2]]];

If[fj≠0,
If[fi≠0,
r=(fi/fj),
r=1;
];
];

If[(r≥1&&r≤threshold)||((r^(-1))≥1&&(r^(-1))≤threshold),
If[eps[[i,j]]≠"NaN",
diag[[index]]={Mean[{fi,fj}],eps[[i,j]]};
index++;
];
];

];
]

(*******************************************************)

(* Group D7 *)
singlekor=Import[StringJoin[path,"FILES2012/h7a_tsq_fake_studentt.dat"]];
singlekoc=Import[StringJoin[path,"FILES2012/h7a_genuinearray_fake_studentt.dat"]];
If[wrong==0,
eps=Import[StringJoin[path,"FILES2012/j7c_epsD_fake_studentt.dat"]],
eps=Import[StringJoin[path,"FILES2012/j7c_epsD_fake_studentt_wrongdef.dat"]];
];

For[i=1,i≤Length[singlekor],i++,
fi=Log[2,singlekor[[i,2]]];
For[j=1,j≤Length[singlekoc],j++,
fj=Log[2,singlekoc[[j,2]]];

If[fj≠0,
If[fi≠0,
r=(fi/fj),
r=1;
];
];

If[(r≥1&&r≤threshold)||((r^(-1))≥1&&(r^(-1))≤threshold),
If[eps[[i,j]]≠"NaN",
diag[[index]]={Mean[{fi,fj}],eps[[i,j]]};
index++;
];
];

];
]

(*******************************************************)

(* Group D8 *)
singlekor=Import[StringJoin[path,"FILES2012/h8a_tsq_fake_studentt.dat"]];
singlekoc=Import[StringJoin[path,"FILES2012/h8a_genuinearray_fake_studentt.dat"]];
If[wrong==0,
eps=Import[StringJoin[path,"FILES2012/j8c_epsD_fake_studentt.dat"]],
eps=Import[StringJoin[path,"FILES2012/j8c_epsD_fake_studentt_wrongdef.dat"]];
];

For[i=1,i≤Length[singlekor],i++,
fi=Log[2,singlekor[[i,2]]];
For[j=1,j≤Length[singlekoc],j++,
fj=Log[2,singlekoc[[j,2]]];

If[fj≠0,
If[fi≠0,
r=(fi/fj),
r=1;
];
];

If[(r≥1&&r≤threshold)||((r^(-1))≥1&&(r^(-1))≤threshold),
If[eps[[i,j]]≠"NaN",
diag[[index]]={Mean[{fi,fj}],eps[[i,j]]};
index++;
];
];

];
]

(*******************************************************)

(* Group D9 *)
singlekor=Import[StringJoin[path,"FILES2012/h9a_tsq_fake_studentt.dat"]];
singlekoc=Import[StringJoin[path,"FILES2012/h9a_genuinearray_fake_studentt.dat"]];
If[wrong==0,
eps=Import[StringJoin[path,"FILES2012/j9c_epsD_fake_studentt.dat"]],
eps=Import[StringJoin[path,"FILES2012/j9c_epsD_fake_studentt_wrongdef.dat"]];
];

For[i=1,i≤Length[singlekor],i++,
fi=Log[2,singlekor[[i,2]]];
For[j=1,j≤Length[singlekoc],j++,
fj=Log[2,singlekoc[[j,2]]];

If[fj≠0,
If[fi≠0,
r=(fi/fj),
r=1;
];
];

If[(r≥1&&r≤threshold)||((r^(-1))≥1&&(r^(-1))≤threshold),
If[eps[[i,j]]≠"NaN",
diag[[index]]={Mean[{fi,fj}],eps[[i,j]]};
index++;
];
];

];
]

index
diag=DeleteCases[diag,0];
Length[diag]


(* DELETERIOUS MUTATIONS *)

uplist={};
midlist={};
lowlist={};
count={};


(*For[mid=-0.1,mid≥Log[2,0.25],mid=mid-0.2,                                          (* linear binning *)*)
For[mid=Log[2,0.995],mid≥Log[2,0.25],mid=Power[2,pow]mid,             (* exponential binning *)

lower=0.5 mid(1+Power[2,-pow]);
upper=0.5 mid(1+Power[2,pow]);
(*lower=mid+0.1;
upper=mid-0.1;*)
distro={};


For[i=1,i≤Length[diag],i++,
If[diag[[i,1]]<upper||diag[[i,1]]>lower,Continue[]];
AppendTo[distro,diag[[i,2]]];
];


If[Length[distro]≥2,

(* begin bootstrap *)
bsvar={};
For[j=1,j≤1000,j++,
bsdistro=RandomChoice[distro,Length[distro]];
AppendTo[bsvar,Variance[bsdistro](*+((Mean[distro])^2)*)];
];
(* end bootstrap *)

AppendTo[uplist,{mid,Quantile[bsvar,(3/4)]}];
AppendTo[midlist,{mid,Variance[distro](*+((Mean[distro])^2)*)}];
AppendTo[lowlist,{mid,Quantile[bsvar,(1/4)]}];
AppendTo[count,{mid,Length[distro]}];

If[mid>-0.1&&((StandardDeviation[distro])^2)>0.01,
Print["z  ",((StandardDeviation[distro])^2),Take[Sort[distro],20]];
];
];

Print[mid]

]

uplistdelnoise=uplist;
midlistdelnoise=midlist;
lowlistdelnoise=lowlist;


(* BENEFICIAL MUTATIONS *)

uplist={};
midlist={};
lowlist={};
count={};

(*For[mid=Log[2,0.999],mid≥Log[2,0.25],mid=mid-0.05,                                          (* linear binning *)*)
For[mid=Log[2,1.01],mid≤Log[2,1.35],mid=Power[2,pow]mid,             (* exponential binning *)

(*lower=alpha mid;
upper=beta mid;
distro={};

For[i=1,i≤Length[diag],i++,
If[diag[[i,1]]>upper||diag[[i,1]]<lower,Continue[]];
AppendTo[distro,diag[[i,2]]];
];*)

lower=0.5 mid(1+Power[2,-pow]);
upper=0.5 mid(1+Power[2,pow]);
distro=Table[666,{Length[diag]}];

For[i=1,i≤Length[diag],i++,
If[diag[[i,1]]>upper||diag[[i,1]]<lower,Continue[]];
distro[[i]]=diag[[i,2]];
];
distro=DeleteCases[distro,666];


If[Length[distro]≥2,

(* begin bootstrap *)
bsvar={};
For[j=1,j≤10,j++,
bsdistro=RandomChoice[distro,Length[distro]];
AppendTo[bsvar,Variance[bsdistro](*+((Mean[distro])^2)*)];
];
(* end bootstrap *)

AppendTo[uplist,{mid,Quantile[bsvar,(3/4)]}];
AppendTo[midlist,{mid,Variance[distro](*+((Mean[distro])^2)*)}];
AppendTo[lowlist,{mid,Quantile[bsvar,(1/4)]}];
AppendTo[count,{mid,Length[distro]}];

If[mid>-0.1&&((StandardDeviation[distro])^2)>0.01,
Print["z  ",((StandardDeviation[distro])^2),Take[Sort[distro],20]];
];
];

Print[mid]

]

uplistbennoise=uplist;
midlistbennoise=midlist;
lowlistbennoise=lowlist;


(* DIFFERENCE *)

uplist=Join[Reverse[uplistdel],uplistben];
midlist=Join[Reverse[midlistdel],midlistben];
lowlist=Join[Reverse[lowlistdel],lowlistben];

uplistnoise=Join[Reverse[uplistdelnoise],uplistbennoise];
midlistnoise=Join[Reverse[midlistdelnoise],midlistbennoise];
lowlistnoise=Join[Reverse[lowlistdelnoise],lowlistbennoise];


lowdifference={};
middifference={};
updifference={};
For[i=1,i≤Length[midlistnoise],i++,
For[j=1,j≤Length[midlist],j++,
If[midlist[[j,1]]==midlistnoise[[i,1]],
AppendTo[lowdifference,{lowlist[[j,1]],lowlist[[j,2]]-uplistnoise[[i,2]]}];
AppendTo[middifference,{midlist[[j,1]],midlist[[j,2]]-midlistnoise[[i,2]]}];
AppendTo[updifference,{uplist[[j,1]],uplist[[j,2]]-lowlistnoise[[i,2]]}];
If[i≠j,Print[i,"  ",j]];
Break[];
];
];
];


Show[ListLinePlot[{updifference,middifference,lowdifference},PlotStyle->{Blue,Directive[Black,Thick],Blue},PlotRange->{{-2,0.2},{-0.02,0.2}},AxesStyle->18,Ticks->{{-2.0,-1.5,-1.0,-0.5,0,0.2},{0.0,0.03,0.06,0.09,0.12}},AspectRatio->1],ListPlot[middifference,PlotStyle->Directive[Black,PointSize[0.02]],PlotRange->All],Plot[-0.069x,{x,-2,0},PlotStyle->Directive[Red,Thick]](*,ListLinePlot[midlist,PlotStyle->Directive[Black,Dashed]]*)]
Show[ListLinePlot[{midlist,midlistnoise},PlotRange->{{-2,0.2},{-0.02,0.5}},AxesStyle->18,AspectRatio->1],ListPlot[midlist,PlotStyle->Directive[Black,PointSize[0.02]],PlotRange->All],Plot[-0.069x,{x,-2,0},PlotStyle->Directive[Red,Thick]](*,ListLinePlot[midlist,PlotStyle->Directive[Black,Dashed]]*)]

updifference
middifference
lowdifference

updifference={{-1.5567361646261124`,0.16810756668279045`},{-1.3090538603299144`,0.10636852562837296`},{-1.1007786985254617`,0.1151749534900593`},{-0.9256408615777101`,0.1258374598087847`},{-0.7783680823130562`,0.06431711702321738`},{-0.6545269301649572`,0.03975335678426464`},{-0.5503893492627309`,0.030702457895565766`},{-0.46282043078885504`,0.023891130621303734`},{-0.3891840411565281`,0.025542661094329962`},{-0.3272634650824786`,0.02215450008676318`},{-0.27519467463136543`,0.02516236876853009`},{-0.23141021539442752`,0.03434617402569881`},{-0.19459202057826405`,0.020150959937481134`},{-0.1636317325412393`,0.02673024768204633`},{-0.13759733731568272`,0.00970977587142135`},{-0.11570510769721376`,0.007915138071873483`},{-0.09729601028913203`,0.025242705293690156`},{-0.08181586627061965`,0.019525177710971175`},{-0.06879866865784136`,0.011076329796760782`},{-0.05785255384860688`,0.002560893400507483`},{-0.04864800514456601`,0.0012274365785442803`},{-0.040907933135309826`,0.028011733318985314`},{-0.03439933432892068`,0.0013205524570364486`},{-0.028926276924303444`,-0.0002625237775087264`},{-0.02432400257228301`,0.003785119089250802`},{-0.020453966567654917`,0.0021484567702201437`},{-0.017199667164460343`,0.00019630830135018316`},{-0.014463138462151725`,0.031086307452405128`},{-0.012162001286141508`,0.005902889254520637`},{-0.01022698328382746`,0.00822140241260682`},{-0.008599833582230173`,0.0012727262313361903`},{-0.0072315692310758635`,0.004136299334086511`},{0.014355292977070055`,-0.001889721774930932`},{0.0170714165462803`,-0.0004786694159282499`},{0.020301450020011713`,-0.0021979833204357003`},{0.02414262880867006`,-0.0013684697914291884`},{0.028710585954140104`,-0.0009544454178078558`},{0.034142833092560596`,0.00004316873666367115`},{0.04060290004002342`,-0.0011141906977962823`},{0.048285257617340115`,-0.0006347287346276922`},{0.057421171908280194`,-0.0005200111467269051`},{0.06828566618512118`,0.001864337753537363`},{0.08120580008004682`,0.020307555317783617`},{0.09657051523468022`,0.0003930949563811391`},{0.11484234381656037`,-0.0008794447765923014`}};

middifference={{-1.5567361646261124`,0.08906248540691397`},{-1.3090538603299144`,0.06932175507270961`},{-1.1007786985254617`,0.013470865649317404`},{-0.9256408615777101`,0.1013094219448443`},{-0.7783680823130562`,0.055134748338736`},{-0.6545269301649572`,0.02606454105801092`},{-0.5503893492627309`,0.02537466599147981`},{-0.46282043078885504`,0.01973336009115259`},{-0.3891840411565281`,0.022326082860155777`},{-0.3272634650824786`,0.018996692755455926`},{-0.27519467463136543`,0.020633377972561796`},{-0.23141021539442752`,0.023572744569282076`},{-0.19459202057826405`,0.01765490414000876`},{-0.1636317325412393`,0.02042146261769482`},{-0.13759733731568272`,0.008208903507637021`},{-0.11570510769721376`,0.006141872658663056`},{-0.09729601028913203`,0.016964869026016367`},{-0.08181586627061965`,0.01422336269351047`},{-0.06879866865784136`,0.008212919183793355`},{-0.05785255384860688`,0.0011563336337224606`},{-0.04864800514456601`,-0.00010595589147610173`},{-0.040907933135309826`,0.02046364038043178`},{-0.03439933432892068`,0.000015123272604299076`},{-0.028926276924303444`,-0.0007958614128447134`},{-0.02432400257228301`,0.002772549662485795`},{-0.020453966567654917`,0.001281332281178731`},{-0.017199667164460343`,-0.00020997514442021433`},{-0.014463138462151725`,0.01583913401446819`},{-0.012162001286141508`,0.0028088736405106124`},{-0.01022698328382746`,0.003443778372901934`},{-0.008599833582230173`,0.0002857025864404245`},{-0.0072315692310758635`,0.002672092567981711`},{0.014355292977070055`,-0.003181682375806569`},{0.0170714165462803`,-0.001155070012939306`},{0.020301450020011713`,-0.0027213029761288953`},{0.02414262880867006`,-0.0023401869228367456`},{0.028710585954140104`,-0.0013277869246428825`},{0.034142833092560596`,-0.0000692279236147223`},{0.04060290004002342`,-0.0013056824778735858`},{0.048285257617340115`,-0.0008504463651896792`},{0.057421171908280194`,-0.0011664494493140562`},{0.06828566618512118`,0.0005515318666040494`},{0.08120580008004682`,0.014864441632384295`},{0.09657051523468022`,-0.0001815599326588748`},{0.11484234381656037`,-0.0015541131546418353`}};

lowdifference={{-1.5567361646261124`,-0.031812758391730644`},{-1.3090538603299144`,0.011501383373540494`},{-1.1007786985254617`,-0.08899746840775827`},{-0.9256408615777101`,0.06949770199424322`},{-0.7783680823130562`,0.04489500091387363`},{-0.6545269301649572`,0.016823275474789103`},{-0.5503893492627309`,0.0201719128744177`},{-0.46282043078885504`,0.015221130457821579`},{-0.3891840411565281`,0.019059401323645336`},{-0.3272634650824786`,0.015626104797189223`},{-0.27519467463136543`,0.015617251464255926`},{-0.23141021539442752`,0.013309337906481394`},{-0.19459202057826405`,0.014625575308296482`},{-0.1636317325412393`,0.013568365173678392`},{-0.13759733731568272`,0.0065236427535961036`},{-0.11570510769721376`,0.004115287582869871`},{-0.09729601028913203`,0.006803167106797117`},{-0.08181586627061965`,0.008375390152166198`},{-0.06879866865784136`,0.004713374238103159`},{-0.05785255384860688`,-0.00012277583083899948`},{-0.04864800514456601`,-0.0013969869295740135`},{-0.040907933135309826`,0.00924187308920878`},{-0.03439933432892068`,-0.0014994674138978457`},{-0.028926276924303444`,-0.0014393319930971538`},{-0.02432400257228301`,0.001634501039977115`},{-0.020453966567654917`,0.0003821136773149332`},{-0.017199667164460343`,-0.0006152041006023609`},{-0.014463138462151725`,0.00009268259839535775`},{-0.012162001286141508`,-0.0010507779017301369`},{-0.01022698328382746`,-0.0023006817333665356`},{-0.008599833582230173`,-0.0010732070285040343`},{-0.0072315692310758635`,0.0004404238761661222`},{0.014355292977070055`,-0.006182725561387105`},{0.0170714165462803`,-0.0024658171623224163`},{0.020301450020011713`,-0.0032180630574041736`},{0.02414262880867006`,-0.003192753340265365`},{0.028710585954140104`,-0.0013390879451387512`},{0.034142833092560596`,-0.0006562699677578371`},{0.04060290004002342`,-0.0018055106694070692`},{0.048285257617340115`,-0.0013904830039538252`},{0.057421171908280194`,-0.001963862762255518`},{0.06828566618512118`,-0.0006983716804823538`},{0.08120580008004682`,0.00486498849310364`},{0.09657051523468022`,-0.0006074544565983605`},{0.11484234381656037`,-0.002001101716026961`}};

upnew=Transpose[{-Log[-Transpose[updifference][[1]]],Log[Transpose[updifference][[2]]/.x_/;x<0.001->0.001]}];
midnew=Transpose[{-Log[-Transpose[middifference][[1]]],Log[Transpose[middifference][[2]]/.x_/;x<0.001->0.001]}];
lownew=Transpose[{-Log[-Transpose[lowdifference][[1]]],Log[Transpose[lowdifference][[2]]/.x_/;x<0.001->0.001]}];

(* for right def *)
Show[ListLinePlot[{upnew,midnew,lownew},PlotStyle->{Directive[Red,Opacity[0.3]],Directive[Red],Directive[Red,Opacity[0.3]]},PlotRange->{{0,-Log[0.03]},{Log[0.002],Log[0.6]}},Filling->{1->{3}},FillingStyle->Directive[Red,Opacity[0.15]],Frame->True,FrameStyle->Directive[18,Thick],AspectRatio->0.75,FrameTicks->{{{-Log[0.001],"0.001"},{-Log[0.03],"0.03"},{-Log[0.1],"0.1"},{-Log[0.3],"0.3"},{-Log[1],"1"}},None,None,{{Log[0.001],"0.001"},{Log[0.003],"0.003"},{Log[0.01],"0.01"},{Log[0.03],"0.03"},{Log[0.1],"0.1"},{Log[0.3],"0.3"}}}],Plot[Log[0.083]-x,{x,-Log[2],5},PlotStyle->Directive[Red,Thick]],ImageSize->300]

Show[,]

Export[StringJoin[path,"FinalFIGS/5b.pdf"],,ImageResolution->600]

(* threshold=1.20 ; pow=0.25 ; right def *)

updifference={{-1.5567361646261124`,0.16953162860771898`},{-1.3090538603299144`,0.10003425186348722`},{-1.1007786985254617`,0.12555118516076022`},{-0.9256408615777101`,0.137046209506126`},{-0.7783680823130562`,0.06728049002377559`},{-0.6545269301649572`,0.04329203142395087`},{-0.5503893492627309`,0.03188372139988673`},{-0.46282043078885504`,0.025231161905693345`},{-0.3891840411565281`,0.026047582512299258`},{-0.3272634650824786`,0.02281213481182459`},{-0.27519467463136543`,0.02600322844447788`},{-0.23141021539442752`,0.035805641902543664`},{-0.19459202057826405`,0.02109566202615653`},{-0.1636317325412393`,0.027152120083313334`},{-0.13759733731568272`,0.009978976961694693`},{-0.11570510769721376`,0.008207915547480429`},{-0.09729601028913203`,0.025347532068491073`},{-0.08181586627061965`,0.01998172095616996`},{-0.06879866865784136`,0.01139039769009725`},{-0.05785255384860688`,0.0025099477001855035`},{-0.04864800514456601`,0.0012668873493998384`},{-0.040907933135309826`,0.029384951299984172`},{-0.03439933432892068`,0.0012169656281588032`},{-0.028926276924303444`,-0.0002232912394852151`},{-0.02432400257228301`,0.0038707470766007534`},{-0.020453966567654917`,0.0021714703860858425`},{-0.017199667164460343`,0.00016236599047040126`},{-0.014463138462151725`,0.0309268275911865`},{-0.012162001286141508`,0.006463321514421449`},{-0.01022698328382746`,0.008564613307060216`},{-0.008599833582230173`,0.001563909003402822`},{-0.0072315692310758635`,0.003951148658132178`},{0.014355292977070055`,-0.002361217641837433`},{0.0170714165462803`,-0.0005599637819223369`},{0.020301450020011713`,-0.0020826194669049574`},{0.02414262880867006`,-0.001927774374707821`},{0.028710585954140104`,-0.0008841739281475727`},{0.034142833092560596`,-0.0001526301418648575`},{0.04060290004002342`,-0.001184027266962023`},{0.048285257617340115`,0.00002823124376313043`},{0.057421171908280194`,-0.00027931924958783964`},{0.06828566618512118`,0.001627915681116952`},{0.08120580008004682`,0.019549348237809426`},{0.09657051523468022`,0.00034891720420098557`},{0.11484234381656037`,-0.0009764318346011608`}};
middifference={{-1.5567361646261124`,0.09616677292838288`},{-1.3090538603299144`,0.06558565866814009`},{-1.1007786985254617`,0.022657282233400772`},{-0.9256408615777101`,0.10695422058708318`},{-0.7783680823130562`,0.05750846157496068`},{-0.6545269301649572`,0.02913272446377408`},{-0.5503893492627309`,0.02671788998483322`},{-0.46282043078885504`,0.02082642037791611`},{-0.3891840411565281`,0.02301072749184492`},{-0.3272634650824786`,0.019571256027766274`},{-0.27519467463136543`,0.021272943298006594`},{-0.23141021539442752`,0.024545246668360294`},{-0.19459202057826405`,0.018410962060834958`},{-0.1636317325412393`,0.020766685814050966`},{-0.13759733731568272`,0.008353496453243618`},{-0.11570510769721376`,0.00629262359947912`},{-0.09729601028913203`,0.017274555405114904`},{-0.08181586627061965`,0.015051006831844332`},{-0.06879866865784136`,0.008434257499299415`},{-0.05785255384860688`,0.0012715595496259587`},{-0.04864800514456601`,-0.00010869009621343809`},{-0.040907933135309826`,0.020557873745431093`},{-0.03439933432892068`,-0.000024783796498998277`},{-0.028926276924303444`,-0.0007823512285257388`},{-0.02432400257228301`,0.0028838285667576033`},{-0.020453966567654917`,0.001301572699962983`},{-0.017199667164460343`,-0.00020968451627602401`},{-0.014463138462151725`,0.015933095901391952`},{-0.012162001286141508`,0.0028683373798830607`},{-0.01022698328382746`,0.003636192580196687`},{-0.008599833582230173`,0.00043914665065478663`},{-0.0072315692310758635`,0.0027598106322329497`},{0.014355292977070055`,-0.0031879802145355503`},{0.0170714165462803`,-0.0011780670767850983`},{0.020301450020011713`,-0.0026991559122152217`},{0.02414262880867006`,-0.0023545145782718595`},{0.028710585954140104`,-0.0013189090188465617`},{0.034142833092560596`,-0.00007024356235986419`},{0.04060290004002342`,-0.0013311300779731406`},{0.048285257617340115`,-0.0008799550688202125`},{0.057421171908280194`,-0.0011621172712551347`},{0.06828566618512118`,0.0006702367868352001`},{0.08120580008004682`,0.014971700205268584`},{0.09657051523468022`,-0.0001828211295593755`},{0.11484234381656037`,-0.0015630369406056395`}};
lowdifference={{-1.5567361646261124`,-0.028311374539126244`},{-1.3090538603299144`,0.011118785764956743`},{-1.1007786985254617`,-0.07563053765321875`},{-0.9256408615777101`,0.07471797013016879`},{-0.7783680823130562`,0.04663610704161635`},{-0.6545269301649572`,0.016884017015519018`},{-0.5503893492627309`,0.021674782256756533`},{-0.46282043078885504`,0.016667083020498515`},{-0.3891840411565281`,0.01983547203669398`},{-0.3272634650824786`,0.016262190540764634`},{-0.27519467463136543`,0.016487562632655973`},{-0.23141021539442752`,0.012149874433672752`},{-0.19459202057826405`,0.015494428066321717`},{-0.1636317325412393`,0.01430662100083319`},{-0.13759733731568272`,0.006673622735477966`},{-0.11570510769721376`,0.00430477286494184`},{-0.09729601028913203`,0.0071762767982264004`},{-0.08181586627061965`,0.009144695051625396`},{-0.06879866865784136`,0.00512212880085613`},{-0.05785255384860688`,0.000028473179020624927`},{-0.04864800514456601`,-0.0014100761664117408`},{-0.040907933135309826`,0.00967510604247254`},{-0.03439933432892068`,-0.0014728073026718524`},{-0.028926276924303444`,-0.0013441302219468505`},{-0.02432400257228301`,0.0017103270941493747`},{-0.020453966567654917`,0.00036941677357452563`},{-0.017199667164460343`,-0.000654663804877879`},{-0.014463138462151725`,0.0002120330650613369`},{-0.012162001286141508`,-0.0008828502488826468`},{-0.01022698328382746`,-0.0021709161138488637`},{-0.008599833582230173`,-0.0008594857825607372`},{-0.0072315692310758635`,0.0004390141201608864`},{0.014355292977070055`,-0.004066398407545564`},{0.0170714165462803`,-0.001918353222283425`},{0.020301450020011713`,-0.0029773280524839157`},{0.02414262880867006`,-0.002937058872416112`},{0.028710585954140104`,-0.0013985278065684228`},{0.034142833092560596`,-0.0010221542665375997`},{0.04060290004002342`,-0.001691150758611178`},{0.048285257617340115`,-0.000968157800081834`},{0.057421171908280194`,-0.0018478248636477031`},{0.06828566618512118`,5.1037671390825184`*^-6},{0.08120580008004682`,0.004918722427009601`},{0.09657051523468022`,-0.0003841305589218822`},{0.11484234381656037`,-0.0022922827319116854`}};

(* threshold=1.20 ; pow=0.125 ; right def *)
updifference={{-1.6976328252444324`,0.34191143610750047`},{-1.5567361646261135`,-0.07489365762909556`},{-1.4275333571650788`,0.18576120026384152`},{-1.3090538603299153`,0.10262307880588864`},{-1.2004076826952153`,0.2611547517390661`},{-1.1007786985254624`,0.10034841803717305`},{-1.009418517221425`,0.1467262055744988`},{-0.9256408615777107`,0.07034046575759276`},{-0.8488164126222162`,0.17559287730844883`},{-0.7783680823130568`,0.07533542070078088`},{-0.7137666785825394`,0.04117390911430854`},{-0.6545269301649577`,0.0521070492527414`},{-0.6002038413476076`,0.04013570346144865`},{-0.5503893492627312`,0.032971492511617656`},{-0.5047092586107125`,0.020128766807250818`},{-0.4628204307888554`,0.021167192206470124`},{-0.4244082063111081`,0.03388158723064896`},{-0.3891840411565284`,0.02818125840403895`},{-0.3568833392912697`,0.033974647734384536`},{-0.32726346508247883`,0.01101911161323337`},{-0.3001019206738038`,0.020327487593363246`},{-0.2751946746313656`,0.03814640983388155`},{-0.25235462930535624`,0.049628510697604294`},{-0.2314102153944277`,0.016419088530645408`},{-0.21220410315555405`,0.021015718311718605`},{-0.1945920205782642`,0.02146628325514028`},{-0.17844166964563485`,0.03737525717826145`},{-0.16363173254123942`,0.017476824571240515`},{-0.1500509603369019`,0.009434557444868166`},{-0.1375973373156828`,0.009713529995276603`},{-0.12617731465267812`,0.006081312449542832`},{-0.11570510769721384`,0.0031617313705861747`},{-0.10610205157777702`,0.03044928731915569`},{-0.0972960102891321`,0.010790179522641061`},{-0.08922083482281742`,0.03788032540340698`},{-0.08181586627061971`,0.011151450444926051`},{-0.07502548016845095`,0.017358298066153018`},{-0.0687986686578414`,0.004794859260906449`},{-0.06308865732633906`,0.0045640287528220915`},{-0.05785255384860692`,0.004586934909570029`},{-0.05305102578888851`,0.0010430093040941866`},{-0.04864800514456605`,0.0000763164661713527`},{-0.04461041741140871`,0.00762960080478672`},{-0.040907933135309854`,0.047735266271158726`},{-0.03751274008422548`,0.000017690828534501317`},{-0.0343993343289207`,-0.0008354450390532118`},{-0.03154432866316953`,0.0023959025717467716`},{-0.02892627692430346`,0.0008291442769790768`},{-0.026525512894444256`,0.004388365583174835`},{-0.024324002572283024`,0.0023907476638395505`},{-0.022305208705704356`,0.004781448683014571`},{-0.020453966567654927`,0.0032095166363970058`},{-0.01875637004211274`,0.0019651812614419548`},{-0.01719966716446035`,-0.0005208335293942516`},{-0.015772164331584765`,0.00116974357475912`},{-0.014463138462151729`,0.001931237264636333`},{-0.013262756447222126`,0.0445018118929173`},{-0.01216200128614151`,0.0121910755683958`},{-0.011152604352852176`,-0.0017145532654629834`},{-0.010226983283827462`,0.031714316622959815`},{-0.008599833582230173`,0.0017936775112799065`},{-0.00788608216579238`,0.007244118563002974`},{-0.0072315692310758635`,0.0024919514085509995`},{0.014355292977070055`,0.00007359056024759019`},{0.015654557996170163`,-0.0017214600347271103`},{0.017071416546280305`,0.0006280677245899396`},{0.02030145002001172`,-0.0026937323533334856`},{0.02213888823114003`,-0.0015854582012333395`},{0.02414262880867007`,0.0011665463243271386`},{0.026327723402721732`,-0.0025016147112605753`},{0.028710585954140118`,-0.001280055549836196`},{0.03130911599234033`,0.0013983751820192537`},{0.03723302350253661`,0.00031569232108653476`},{0.04060290004002345`,-0.0011525722386649291`},{0.04427777646228007`,0.000720704952162793`},{0.048285257617340156`,0.000533133817134704`},{0.05265544680544348`,-0.00014000913544098695`},{0.05742117190828025`,-0.0006692829861637219`},{0.06261823198468068`,-0.001118235354000602`},{0.06828566618512125`,0.0024016453724814424`},{0.07446604700507323`,9.984181422247008`*^-6},{0.08120580008004691`,0.03861038089996529`},{0.08855555292456016`,0.011459149988124796`},{0.09657051523468033`,-0.00003819728421505949`},{0.10531089361088697`,-0.0002569224808327908`},{0.11484234381656053`,-0.0013233264623912998`}};
middifference={{-1.6976328252444324`,0.3057822467383277`},{-1.5567361646261135`,-0.13740252233873282`},{-1.4275333571650788`,0.1313333909711472`},{-1.3090538603299153`,0.07127198229670371`},{-1.2004076826952153`,0.1804569264049281`},{-1.1007786985254624`,-0.1262992423175788`},{-1.009418517221425`,0.12312533715979228`},{-0.9256408615777107`,0.05071205942060563`},{-0.8488164126222162`,0.1402052569805416`},{-0.7783680823130568`,0.06319666254451926`},{-0.7137666785825394`,0.03320153068398333`},{-0.6545269301649577`,0.0423585953832873`},{-0.6002038413476076`,0.020431979667328078`},{-0.5503893492627312`,0.025642087271919415`},{-0.5047092586107125`,0.015159210202273368`},{-0.4628204307888554`,0.014540458083243737`},{-0.4244082063111081`,0.029240084939328816`},{-0.3891840411565284`,0.023418767900478466`},{-0.3568833392912697`,0.028012805883729994`},{-0.32726346508247883`,0.008761976524611047`},{-0.3001019206738038`,0.017783029675951318`},{-0.2751946746313656`,0.03084208960816085`},{-0.25235462930535624`,0.03585217964628584`},{-0.2314102153944277`,0.0016377488977692006`},{-0.21220410315555405`,0.018399028699914523`},{-0.1945920205782642`,0.01735059358899692`},{-0.17844166964563485`,0.030390351289729604`},{-0.16363173254123942`,0.013608538184333333`},{-0.1500509603369019`,0.003694059427078785`},{-0.1375973373156828`,0.007508929280524471`},{-0.12617731465267812`,0.0046549812308751895`},{-0.11570510769721384`,0.0021348555976434588`},{-0.10610205157777702`,0.022231019044582044`},{-0.0972960102891321`,0.008707830788775493`},{-0.08922083482281742`,0.027222493564349838`},{-0.08181586627061971`,0.008509213158321356`},{-0.07502548016845095`,0.011810101900727848`},{-0.0687986686578414`,0.0029920156132542492`},{-0.06308865732633906`,0.002598222627148086`},{-0.05785255384860692`,0.0022291366797329787`},{-0.05305102578888851`,-0.001509833545244344`},{-0.04864800514456605`,-0.0010054486619787157`},{-0.04461041741140871`,0.005523189252755029`},{-0.040907933135309854`,0.03269450197238466`},{-0.03751274008422548`,-0.0006246281331385739`},{-0.0343993343289207`,-0.0019131415126560315`},{-0.03154432866316953`,0.00012035397966535764`},{-0.02892627692430346`,0.0001665424249640661`},{-0.026525512894444256`,0.0029773411471219306`},{-0.024324002572283024`,0.0013210833578567757`},{-0.022305208705704356`,0.0034116792524819333`},{-0.020453966567654927`,0.0022988346279132123`},{-0.01875637004211274`,0.0004305019758382338`},{-0.01719966716446035`,-0.00091032228838104`},{-0.015772164331584765`,0.0004025187381118626`},{-0.014463138462151729`,0.001295403708740467`},{-0.013262756447222126`,0.021937393125274606`},{-0.01216200128614151`,0.006494839907015937`},{-0.011152604352852176`,-0.0025750241300508013`},{-0.010226983283827462`,0.02024137049588166`},{-0.008599833582230173`,0.00045125913748704895`},{-0.00788608216579238`,0.005532879114607989`},{-0.0072315692310758635`,0.0014221418077338828`},{0.014355292977070055`,-0.003095105653623232`},{0.015654557996170163`,-0.0040043289308251085`},{0.017071416546280305`,-0.00013429602475887757`},{0.02030145002001172`,-0.003297747592575829`},{0.02213888823114003`,-0.0022489363594387`},{0.02414262880867007`,-0.00035292598967312776`},{0.026327723402721732`,-0.003508412112777231`},{0.028710585954140118`,-0.00182687397240703`},{0.03130911599234033`,0.0005538335383021369`},{0.03723302350253661`,-0.00018955562347050883`},{0.04060290004002345`,-0.0015033007259681104`},{0.04427777646228007`,-0.00048325000745823125`},{0.048285257617340156`,-0.0008933648796942799`},{0.05265544680544348`,-0.0007615091500227872`},{0.05742117190828025`,-0.000789291464528359`},{0.06261823198468068`,-0.002399390902969825`},{0.06828566618512125`,0.00254713893533645`},{0.07446604700507323`,-0.000292758766069635`},{0.08120580008004691`,0.0190405189344423`},{0.08855555292456016`,0.011244585866810994`},{0.09657051523468033`,-0.000029338184786157793`},{0.10531089361088697`,-0.00038860570497802624`},{0.11484234381656053`,-0.0029243471372790352`}};
lowdifference={{-1.6976328252444324`,0.114747701914306`},{-1.5567361646261135`,-0.22098989607026034`},{-1.4275333571650788`,-0.02761127666577242`},{-1.3090538603299153`,-0.01181058639559085`},{-1.2004076826952153`,0.06266090536173999`},{-1.1007786985254624`,-0.3347216696374409`},{-1.009418517221425`,0.0925050259749081`},{-0.9256408615777107`,0.03255039770751578`},{-0.8488164126222162`,0.09067845285128015`},{-0.7783680823130568`,0.0496507509233665`},{-0.7137666785825394`,0.024074871747253035`},{-0.6545269301649577`,0.03182358337614193`},{-0.6002038413476076`,0.0027675446651798385`},{-0.5503893492627312`,0.018007732725185386`},{-0.5047092586107125`,0.00999989526081001`},{-0.4628204307888554`,0.00794765060971463`},{-0.4244082063111081`,0.02532693007641802`},{-0.3891840411565284`,0.018201315340237438`},{-0.3568833392912697`,0.020846287259410477`},{-0.32726346508247883`,0.005932509309856974`},{-0.3001019206738038`,0.015029006580805047`},{-0.2751946746313656`,0.021995829936944114`},{-0.25235462930535624`,0.021971319486332207`},{-0.2314102153944277`,-0.010951439778711176`},{-0.21220410315555405`,0.01450623216385111`},{-0.1945920205782642`,0.013042875274706819`},{-0.17844166964563485`,0.022837501056760356`},{-0.16363173254123942`,0.00949925639068531`},{-0.1500509603369019`,-0.0012314210074174`},{-0.1375973373156828`,0.005060338459281846`},{-0.12617731465267812`,0.0029402779567010437`},{-0.11570510769721384`,0.0012194013144528667`},{-0.10610205157777702`,0.009994111150288913`},{-0.0972960102891321`,0.0062538192146909906`},{-0.08922083482281742`,0.014787069726226896`},{-0.08181586627061971`,0.005523940560295466`},{-0.07502548016845095`,0.005526080087090724`},{-0.0687986686578414`,0.0011002152652055614`},{-0.06308865732633906`,0.0005144705801896693`},{-0.05785255384860692`,-0.00027730085885790436`},{-0.05305102578888851`,-0.00383414003731593`},{-0.04864800514456605`,-0.0020300685613561984`},{-0.04461041741140871`,0.0032021189326767435`},{-0.040907933135309854`,0.012033619631092464`},{-0.03751274008422548`,-0.0012453268442174292`},{-0.0343993343289207`,-0.002955610089459625`},{-0.03154432866316953`,-0.0026712723021455266`},{-0.02892627692430346`,-0.0005290235093076238`},{-0.026525512894444256`,0.0012499426766017143`},{-0.024324002572283024`,-0.00027808634139326206`},{-0.022305208705704356`,0.001651749982797602`},{-0.020453966567654927`,0.0012442235139090933`},{-0.01875637004211274`,-0.0012139677468996678`},{-0.01719966716446035`,-0.0013294328180061413`},{-0.015772164331584765`,-0.0005070276914929573`},{-0.014463138462151729`,0.00042583171874966243`},{-0.013262756447222126`,-0.001537359254591912`},{-0.01216200128614151`,0.00012812428854563386`},{-0.011152604352852176`,-0.0033569807110422466`},{-0.010226983283827462`,0.00136885981641156`},{-0.008599833582230173`,-0.0010880281472286212`},{-0.00788608216579238`,0.0028055592810384954`},{-0.0072315692310758635`,-0.00003911328952360118`},{0.014355292977070055`,-0.0041654165670564625`},{0.015654557996170163`,-0.004985907932060508`},{0.017071416546280305`,-0.0005379353963293992`},{0.02030145002001172`,-0.004189199528493258`},{0.02213888823114003`,-0.0026084382005125044`},{0.02414262880867007`,-0.0023377074619278116`},{0.026327723402721732`,-0.004229698485875974`},{0.028710585954140118`,-0.0023428660376784054`},{0.03130911599234033`,-0.0003455215688237456`},{0.03723302350253661`,-0.0004203416298721116`},{0.04060290004002345`,-0.00215770659597719`},{0.04427777646228007`,-0.0012535443419290978`},{0.048285257617340156`,-0.0016683745455592256`},{0.05265544680544348`,-0.0013642289671419482`},{0.05742117190828025`,-0.0011046583047535224`},{0.06261823198468068`,-0.003861904353438898`},{0.06828566618512125`,-0.0007806982887552931`},{0.07446604700507323`,-0.0004020954306055227`},{0.08120580008004691`,-0.0005908677869462138`},{0.08855555292456016`,-0.0004657393678029118`},{0.09657051523468033`,-0.0007451010766438356`},{0.10531089361088697`,-0.0006150796189718825`},{0.11484234381656053`,-0.0032308404623851944`}};

upnew=Transpose[{-Log[-Transpose[updifference][[1]]],Log[Transpose[updifference][[2]]/.x_/;x<0.0003->0.0003]}];
midnew=Transpose[{-Log[-Transpose[middifference][[1]]],Log[Transpose[middifference][[2]]/.x_/;x<0.0003->0.0003]}];
lownew=Transpose[{-Log[-Transpose[lowdifference][[1]]],Log[Transpose[lowdifference][[2]]/.x_/;x<0.0003->0.0003]}];

(* for right def *)
Show[ListLinePlot[{upnew,midnew,lownew},PlotStyle->{Blue,Directive[Black,Thick],Blue},PlotRange->{{-Log[2],-Log[0.03]},{Log[0.001],Log[0.6]}},Filling->{1->{3}},FillingStyle->Directive[Red,Opacity[0.2]],AxesStyle->18,AspectRatio->0.8,AxesOrigin->{-Log[0.03],Log[0.001]},Ticks->{{{-Log[0.001],"0.001"},{-Log[0.03],"0.03"},{-Log[0.1],"0.1"},{-Log[0.3],"0.3"},{-Log[1],"1"}},{{Log[0.001],"0.001"},{Log[0.003],"0.003"},{Log[0.01],"0.01"},{Log[0.03],"0.03"},{Log[0.1],"0.1"},{Log[0.3],"0.3"}}}],Plot[Log[0.069]-x,{x,-Log[2],5},PlotStyle->Directive[Red,Thick]]]

(* threshold=1.20 ; pow=0.25 ; right def *)

(* threshold=1.20 ; pow=0.125 ; right def *)

(* for right def to compare with ABC *)
Show[ListLinePlot[{upnew,lownew},PlotStyle->{Red,Red},PlotRange->{{-Log[2],-Log[0.03]},{Log[0.001],Log[0.6]}},Filling->{1->{2}},FillingStyle->Directive[Red,Opacity[0.2]],AxesStyle->18,AspectRatio->0.8,AxesOrigin->{-Log[0.03],Log[0.001]},Ticks->{{{-Log[0.001],"0.001"},{-Log[0.03],"0.03"},{-Log[0.1],"0.1"},{-Log[0.3],"0.3"},{-Log[1],"1"}},{{Log[0.001],"0.001"},{Log[0.003],"0.003"},{Log[0.01],"0.01"},{Log[0.03],"0.03"},{Log[0.1],"0.1"},{Log[0.3],"0.3"}}}]]

Show[,]

Export["tsqcompare2.png",]