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

nnanpoints=Import[StringJoin[path,"FILES2012/d_nnanpointsA.dat"]];
npoints=Import[StringJoin[path,"FILES2012/d_npointsA.dat"]];
delta1=Import[StringJoin[path,"FILES2012/d_delta1A.dat"]];
delta2=Import[StringJoin[path,"FILES2012/d_delta2A.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/d_binxA.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/d_nxA.dat"]]];

q25=Import[StringJoin[path,"FILES2012/d_q25A.dat"]];
q50=Import[StringJoin[path,"FILES2012/d_q50A.dat"]];
q75=Import[StringJoin[path,"FILES2012/d_q75A.dat"]];
q90=Import[StringJoin[path,"FILES2012/d_q90A.dat"]];

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={};

eps25={};
eps50={};
eps75={};
eps90={};

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

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

If[npoints[[i,j]]>1,
AppendTo[nangrid,{x,y,Log[10,nnanpoints[[i,j]]]}];
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]]-1))(*-((npoints[[i,j]])/(npoints[[i,j]]-1))((avgdelta1[[i,j]])^2)*)}];
AppendTo[epssigma,{x,y,Sqrt[((delta2[[i,j]])/(npoints[[i,j]]-1))(*-((npoints[[i,j]])/(npoints[[i,j]]-1))((avgdelta1[[i,j]])^2)*)]}];

AppendTo[eps25,{x,y,Sqrt[q25[[i,j]]]}];
AppendTo[eps50,{x,y,Sqrt[q50[[i,j]]]}];
AppendTo[eps75,{x,y,Sqrt[q75[[i,j]]]}];
AppendTo[eps90,{x,y,Sqrt[q90[[i,j]]]}];
];
];
];
(*ListPlot3D[nangrid,PlotRange->All,AxesStyle->18]*)
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]

p25=ListPlot3D[eps25,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p50=ListPlot3D[eps50,PlotRange->All,AxesStyle->18,PlotStyle->Red]
p75=ListPlot3D[eps75,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p90=ListPlot3D[eps90,PlotRange->All,AxesStyle->18,PlotStyle->Yellow]

Show[p25,p50,p75,p90,prms]

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

nnanpoints=Import[StringJoin[path,"FILES2012/d_nnanpointsB.dat"]];
npoints=Import[StringJoin[path,"FILES2012/d_npointsB.dat"]];
delta1=Import[StringJoin[path,"FILES2012/d_delta1B.dat"]];
delta2=Import[StringJoin[path,"FILES2012/d_delta2B.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/d_binxB.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/d_nxB.dat"]]];

q25=Import[StringJoin[path,"FILES2012/d_q25B.dat"]];
q50=Import[StringJoin[path,"FILES2012/d_q50B.dat"]];
q75=Import[StringJoin[path,"FILES2012/d_q75B.dat"]];
q90=Import[StringJoin[path,"FILES2012/d_q90B.dat"]];

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={};

eps25={};
eps50={};
eps75={};
eps90={};

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

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

If[npoints[[i,j]]>1,
AppendTo[nangrid,{x,y,Log[10,nnanpoints[[i,j]]]}];
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]]-1))(*-((npoints[[i,j]])/(npoints[[i,j]]-1))((avgdelta1[[i,j]])^2)*)}];
AppendTo[epssigma,{x,y,Sqrt[((delta2[[i,j]])/(npoints[[i,j]]-1))(*-((npoints[[i,j]])/(npoints[[i,j]]-1))((avgdelta1[[i,j]])^2)*)]}];

AppendTo[eps25,{x,y,Sqrt[q25[[i,j]]]}];
AppendTo[eps50,{x,y,Sqrt[q50[[i,j]]]}];
AppendTo[eps75,{x,y,Sqrt[q75[[i,j]]]}];
AppendTo[eps90,{x,y,Sqrt[q90[[i,j]]]}];
];
];
];
(*ListPlot3D[nangrid,PlotRange->All,AxesStyle->18]*)
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]

p25=ListPlot3D[eps25,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p50=ListPlot3D[eps50,PlotRange->All,AxesStyle->18,PlotStyle->Red]
p75=ListPlot3D[eps75,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p90=ListPlot3D[eps90,PlotRange->All,AxesStyle->18,PlotStyle->Yellow]

Show[p25,p50,p75,p90,prms]

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

nnanpoints=Import[StringJoin[path,"FILES2012/d_nnanpointsC.dat"]];
npoints=Import[StringJoin[path,"FILES2012/d_npointsC.dat"]];
delta1=Import[StringJoin[path,"FILES2012/d_delta1C.dat"]];
delta2=Import[StringJoin[path,"FILES2012/d_delta2C.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/d_binxC.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/d_nxC.dat"]]];

q25=Import[StringJoin[path,"FILES2012/d_q25C.dat"]];
q50=Import[StringJoin[path,"FILES2012/d_q50C.dat"]];
q75=Import[StringJoin[path,"FILES2012/d_q75C.dat"]];
q90=Import[StringJoin[path,"FILES2012/d_q90C.dat"]];

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={};

eps25={};
eps50={};
eps75={};
eps90={};

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

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

If[npoints[[i,j]]>1,
AppendTo[nangrid,{x,y,Log[10,nnanpoints[[i,j]]]}];
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]]-1))(*-((npoints[[i,j]])/(npoints[[i,j]]-1))((avgdelta1[[i,j]])^2)*)}];
AppendTo[epssigma,{x,y,Sqrt[((delta2[[i,j]])/(npoints[[i,j]]-1))(*-((npoints[[i,j]])/(npoints[[i,j]]-1))((avgdelta1[[i,j]])^2)*)]}];

AppendTo[eps25,{x,y,Sqrt[q25[[i,j]]]}];
AppendTo[eps50,{x,y,Sqrt[q50[[i,j]]]}];
AppendTo[eps75,{x,y,Sqrt[q75[[i,j]]]}];
AppendTo[eps90,{x,y,Sqrt[q90[[i,j]]]}];
];
];
];
(*ListPlot3D[nangrid,PlotRange->All,AxesStyle->18]*)
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]

p25=ListPlot3D[eps25,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p50=ListPlot3D[eps50,PlotRange->All,AxesStyle->18,PlotStyle->Red]
p75=ListPlot3D[eps75,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p90=ListPlot3D[eps90,PlotRange->All,AxesStyle->18,PlotStyle->Yellow]

Show[p25,p50,p75,p90,prms]

(* 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 *)

nnanpoints=Import[StringJoin[path,"FILES2012/d_nnanpointsD.dat"]];
npoints=Import[StringJoin[path,"FILES2012/d_npointsD.dat"]];
delta1=Import[StringJoin[path,"FILES2012/d_delta1D.dat"]];
delta2=Import[StringJoin[path,"FILES2012/d_delta2D.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/d_binxD.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/d_nxD.dat"]]];

q25=Import[StringJoin[path,"FILES2012/d_q25D.dat"]];
q50=Import[StringJoin[path,"FILES2012/d_q50D.dat"]];
q75=Import[StringJoin[path,"FILES2012/d_q75D.dat"]];
q90=Import[StringJoin[path,"FILES2012/d_q90D.dat"]];

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={};

eps25={};
eps50={};
eps75={};
eps90={};

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

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

If[npoints[[i,j]]>1,
AppendTo[nangrid,{x,y,Log[10,nnanpoints[[i,j]]]}];
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]]))]}];

AppendTo[eps25,{x,y,Sqrt[q25[[i,j]]]}];
AppendTo[eps50,{x,y,Sqrt[q50[[i,j]]]}];
AppendTo[eps75,{x,y,Sqrt[q75[[i,j]]]}];
AppendTo[eps90,{x,y,Sqrt[q90[[i,j]]]}];
];
];
];
(*ListPlot3D[nangrid,PlotRange->All,AxesStyle->18]*)
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]

p25=ListPlot3D[eps25,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p50=ListPlot3D[eps50,PlotRange->All,AxesStyle->18,PlotStyle->Red]
p75=ListPlot3D[eps75,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p90=ListPlot3D[eps90,PlotRange->All,AxesStyle->18,PlotStyle->Yellow]

Show[p25,p50,p75,p90,prms]

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

nnanpoints=Import[StringJoin[path,"FILES2012/d_nnanpointsE.dat"]];
npoints=Import[StringJoin[path,"FILES2012/d_npointsE.dat"]];
delta1=Import[StringJoin[path,"FILES2012/d_delta1E.dat"]];
delta2=Import[StringJoin[path,"FILES2012/d_delta2E.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/d_binxE.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/d_nxE.dat"]]];

q25=Import[StringJoin[path,"FILES2012/d_q25E.dat"]];
q50=Import[StringJoin[path,"FILES2012/d_q50E.dat"]];
q75=Import[StringJoin[path,"FILES2012/d_q75E.dat"]];
q90=Import[StringJoin[path,"FILES2012/d_q90E.dat"]];

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={};

eps25={};
eps50={};
eps75={};
eps90={};

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

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

If[npoints[[i,j]]>1,
AppendTo[nangrid,{x,y,Log[10,nnanpoints[[i,j]]]}];
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]]-1))(*-((npoints[[i,j]])/(npoints[[i,j]]-1))((avgdelta1[[i,j]])^2)*)}];
AppendTo[epssigma,{x,y,Sqrt[((delta2[[i,j]])/(npoints[[i,j]]-1))(*-((npoints[[i,j]])/(npoints[[i,j]]-1))((avgdelta1[[i,j]])^2)*)]}];

AppendTo[eps25,{x,y,Sqrt[q25[[i,j]]]}];
AppendTo[eps50,{x,y,Sqrt[q50[[i,j]]]}];
AppendTo[eps75,{x,y,Sqrt[q75[[i,j]]]}];
AppendTo[eps90,{x,y,Sqrt[q90[[i,j]]]}];
];
];
];
(*ListPlot3D[nangrid,PlotRange->All,AxesStyle->18]*)
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]

p25=ListPlot3D[eps25,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p50=ListPlot3D[eps50,PlotRange->All,AxesStyle->18,PlotStyle->Red]
p75=ListPlot3D[eps75,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p90=ListPlot3D[eps90,PlotRange->All,AxesStyle->18,PlotStyle->Yellow]

Show[p25,p50,p75,p90,prms]

(* Go back from exponential binning to linear scale and plot: number of points, average deviation from the linear model, variance and standard deviation. Groups A, B and C combined. *)

nnanpoints=Import[StringJoin[path,"FILES2012/d_nnanpointsABC.dat"]];
npoints=Import[StringJoin[path,"FILES2012/d_npointsABC.dat"]];
delta1=Import[StringJoin[path,"FILES2012/d_delta1ABC.dat"]];
delta2=Import[StringJoin[path,"FILES2012/d_delta2ABC.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/d_binxABC.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/d_nxABC.dat"]]];

q25=Import[StringJoin[path,"FILES2012/d_q25ABC.dat"]];
q50=Import[StringJoin[path,"FILES2012/d_q50ABC.dat"]];
q75=Import[StringJoin[path,"FILES2012/d_q75ABC.dat"]];
q90=Import[StringJoin[path,"FILES2012/d_q90ABC.dat"]];

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={};
epssigma2={};

eps25={};
eps50={};
eps75={};
eps90={};

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

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

If[npoints[[i,j]]>4,   (* the (-2,-2) bin has only 4 points *)
AppendTo[nangrid,{x,y,Log[10,nnanpoints[[i,j]]]}];
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)]}];
AppendTo[epssigma2,{x,y,((delta2[[i,j]])/(npoints[[i,j]]))-(((((delta1[[i,j]])/(npoints[[i,j]]))))^2)}];

AppendTo[eps25,{x,y,Sqrt[q25[[i,j]]]}];
AppendTo[eps50,{x,y,Sqrt[q50[[i,j]]]}];
AppendTo[eps75,{x,y,Sqrt[q75[[i,j]]]}];
AppendTo[eps90,{x,y,Sqrt[q90[[i,j]]]}];
];
];
];
(*ListPlot3D[nangrid,PlotRange->All,AxesStyle->18]*)
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]

p25=ListPlot3D[eps25,PlotRange->All(*{{-1,0.2},{-1,0.2},{0,0.6}}*),AxesStyle->18,PlotStyle->Orange]
p50=ListPlot3D[eps50,PlotRange->All,AxesStyle->18,PlotStyle->Red]
p75=ListPlot3D[eps75,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p90=ListPlot3D[eps90,PlotRange->All,AxesStyle->18,PlotStyle->Yellow]

Show[p25,p50,p75,p90,prms]

(* Go back from exponential binning to linear scale and plot: number of points, average deviation from the linear model, variance and standard deviation. Groups A, B and C combined. *)

nnanpoints=Import[StringJoin[path,"FILES2012/d_nnanpointsABC_wrongdef.dat"]];
npoints=Import[StringJoin[path,"FILES2012/d_npointsABC_wrongdef.dat"]];
delta1=Import[StringJoin[path,"FILES2012/d_delta1ABC_wrongdef.dat"]];
delta2=Import[StringJoin[path,"FILES2012/d_delta2ABC_wrongdef.dat"]];
binx=Flatten[Import[StringJoin[path,"FILES2012/d_binxABC_wrongdef.dat"]]];
nx=Flatten[Import[StringJoin[path,"FILES2012/d_nxABC_wrongdef.dat"]]];

q25=Import[StringJoin[path,"FILES2012/d_q25ABC_wrongdef.dat"]];
q50=Import[StringJoin[path,"FILES2012/d_q50ABC_wrongdef.dat"]];
q75=Import[StringJoin[path,"FILES2012/d_q75ABC_wrongdef.dat"]];
q90=Import[StringJoin[path,"FILES2012/d_q90ABC_wrongdef.dat"]];

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={};

eps25={};
eps50={};
eps75={};
eps90={};

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

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

If[npoints[[i,j]]>4,   (* the (-2,-2) bin has only 4 points *)
AppendTo[nangrid,{x,y,Log[10,nnanpoints[[i,j]]]}];
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]]))]}];

AppendTo[eps25,{x,y,Sqrt[q25[[i,j]]]}];
AppendTo[eps50,{x,y,Sqrt[q50[[i,j]]]}];
AppendTo[eps75,{x,y,Sqrt[q75[[i,j]]]}];
AppendTo[eps90,{x,y,Sqrt[q90[[i,j]]]}];
];
];
];
(*ListPlot3D[nangrid,PlotRange->All,AxesStyle->18]*)
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]

p25=ListPlot3D[eps25,PlotRange->All(*{{-1,0.2},{-1,0.2},{0,0.6}}*),AxesStyle->18,PlotStyle->Orange]
p50=ListPlot3D[eps50,PlotRange->All,AxesStyle->18,PlotStyle->Red]
p75=ListPlot3D[eps75,PlotRange->All,AxesStyle->18,PlotStyle->Orange]
p90=ListPlot3D[eps90,PlotRange->All,AxesStyle->18,PlotStyle->Yellow]

Show[p25,p50,p75,p90,prms]