Prime spacings in successive 100000blocks and 
in the first 10 million

CTJ Dodson

SetDirectory["C:/ALLWORK/GEOMETRY/INFOGEOM/Primes"]
PrimeDiff[n_]:=Table[{Prime[k+1]-Prime[k]}, {k,1,n}]

Block 1

PHK=Tally[PrimeDiff[100000]]
Length[PHK]

HPm=BarChart[Table[PHK[[k,2]],{k,1,30}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000//N,(Sqrt[(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000])//N ,
√((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000)/((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000) //N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/100000//N
LM= Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000]//N

Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.74,1.742}]

Unit mean gamma histogram

gk[κ_,s_]:=(((E^(-s κ)) κ (((s κ))^(-1+κ)))/(Gamma[κ]))
lgampfit1=ListPlot[Table[{k+.5,100000(∫_(8.7713(k-1) /54)^(8.7713k/54))gk[1.7408,s]\[DifferentialD]s//Evaluate},{k,1,32}],Frame->True,GridLines->Automatic,PlotStyle->{RGBColor[1,.07,0],AbsolutePointSize[5]}, PlotRange->All]

Show[HPm,lgampfit1]

lgampfit2=ListPlot[Table[{k+.5,(∫_(8.7713(k-1) /54)^(8.7713k/54))gk[1.50788,s]\[DifferentialD]s//Evaluate},{k,1,32}],Frame->True,GridLines->Automatic,PlotStyle->{RGBColor[1,.07,0],AbsolutePointSize[5]}, PlotRange->All]

Show[HPm,lgampfit2]

Block 2

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,100000,200001}]]

BarChart[Table[PHK[[k,2]],{k,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000//N,(Sqrt[(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000])//N ,
√((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000)/((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000) //N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/100000//N
LM= Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000]//N

Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.5,1.8},PlotRange->{-.1,.1}]

Block 3

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,200000,300001}]]

Length[PHK]

BarChart[Table[PHK[[k,2]],{k,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000//N,(Sqrt[(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000])//N ,
√((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000)/((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000) //N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/100000//N
LM= Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000]//N

Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.5,1.84}]

Block 4

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,300000,400001}]];
Length[PHK]

BarChart[Table[PHK[[k,2]],{k,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000//N,(Sqrt[(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000])//N ,
√((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000)/((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000) //N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/100000//N
LM= Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000]//N

Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.5,1.84}]

Block 5

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,400000,500001}]]
Length[PHK]

BarChart[Table[PHK[[k,2]],{k,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000//N,(Sqrt[(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000])//N ,
√((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000)/((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000) //N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/100000//N
LM= Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000]//N

Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.5,1.84}]

Block 6

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,500000,600001}]]
Length[PHK]

BarChart[Table[PHK[[k,2]],{k,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000//N,(Sqrt[(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000])//N ,
√((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000)/((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000) //N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/100000//N
LM= Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000]//N

Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.5,1.84}]

Block 7

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,600000,700001}]]
Length[PHK]

BarChart[Table[PHK[[k,2]],{k,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000//N,(Sqrt[(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000])//N ,
√((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000)/((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000) //N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/100000//N
LM= Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000]//N
Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.5,1.84}]

Block 8

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,700000,800001}]];
Length[PHK]

BarChart[Table[PHK[[k,2]],{k,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000//N,(Sqrt[(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000])//N ,
√((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000)/((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000) //N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/100000//N
LM= Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000]//N
Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.55,1.74}]

Block 9

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,800000,900000}]]
Length[PHK]

BarChart[Table[PHK[[k,2]],{k,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000//N,(Sqrt[(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000])//N ,
√((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000)/((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000) //N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/100000//N
LM= Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000]//N
Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.5,1.84}]

Block 10

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,900000,1000000}]]
Length[PHK]

BarChart[Table[PHK[[k,2]],{k,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000//N,(Sqrt[(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000])//N ,
√((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000)))^2) PHK[[k,2]]/100000)/((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000) //N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/100000//N
LM= Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/100000]//N
Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.5,1.84}]

Block of first 1000000 primes

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,1,1000001}]];
Length[PHK]

PHK

HPm=BarChart[Table[PHK[[b,2]],{b,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/1000000//N,(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/1000000)))^2) PHK[[k,2]]/1000000//N ,((((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/1000000))^2)/((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/1000000)))^2) PHK[[k,2]]/1000000)//N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/1000000//N
LM=Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/1000000]//N

Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.574,1.75}]

Unit mean gamma histogram

gk[κ_,s_]:=(((E^(-s κ)) κ (((s κ))^(-1+κ)))/(Gamma[κ]))
lgampfit=ListPlot[Table[{k+.5,1000000(∫_(8.7713(k-1) /54)^(8.7713k/54))gk[1.63,s]\[DifferentialD]s//Evaluate},{k,1,60}],Frame->True,GridLines->Automatic,PlotStyle->{RGBColor[1,.07,0],AbsolutePointSize[5]}, PlotRange->All]

Show[HPm,%]

Block of second 1000000 primes

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,1000000,2000001}]]
Length[PHK]

HPm=BarChart[Table[PHK[[b,2]],{b,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/1000000//N,(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/1000000)))^2) PHK[[k,2]]/1000000//N ,((((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/1000000))^2)/((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/1000000)))^2) PHK[[k,2]]/1000000)//N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/1000000//N
LM=Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/1000000]//N

Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.574,1.6}]

Unit mean gamma histogram

gk[κ_,s_]:=(((E^(-s κ)) κ (((s κ))^(-1+κ)))/(Gamma[κ]))
lgampfit=ListPlot[Table[{k+.5,1000000(∫_(8.7713(k-1) /54)^(8.7713k/54))gk[1.59,s]\[DifferentialD]s//Evaluate},{k,1,60}],Frame->True,GridLines->Automatic,PlotStyle->{RGBColor[1,.07,0],AbsolutePointSize[5]}, PlotRange->All]

Show[HPm,%]

Block of first 4000000 primes

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,1,4000001}]];
Length[PHK]

PHK

HPm=BarChart[Table[PHK[[b,2]],{b,1,54}],Frame->True,GridLines->Automatic]

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/4000000//N,(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/4000000)))^2) PHK[[k,2]]/4000000//N ,((((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/4000000))^2)/((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/4000000)))^2) PHK[[k,2]]/4000000)//N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/4000000//N
LM=Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/4000000]//N

Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.575,1.58},PlotRange->{-.1,.1}]

Unit mean gamma histogram

gk[κ_,s_]:=(((E^(-s κ)) κ (((s κ))^(-1+κ)))/(Gamma[κ]))
lgampfit=ListPlot[Table[{k+.5,4000000(∫_(8.7713(k-1) /54)^(8.7713k/54))gk[1.58,s]\[DifferentialD]s//Evaluate},{k,1,60}],Frame->True,GridLines->Automatic,PlotStyle->{RGBColor[1,.07,0],AbsolutePointSize[5]}, PlotRange->All]

Show[HPm,%]

Block of first 10000000 primes

PHK=Tally[Table[{Prime[k+1]-Prime[k]}, {k,1,10000001}]];
Length[PHK]

PHK

Original tabulation of first 10 million primes

PHK={{{1},1},{{2},738597},{{4},738717},{{6},1297541},{{8},566151},{{14},503524},{{10},729808},{{12},920661},{{18},667735},{{20},354267},{{22},307230},{{34},129043},{{24},453215},{{16},371677},{{26},211203},{{28},229177},{{30},398713},{{32},123123},{{36},206722},{{44},64866},{{42},159956},{{40},111546},{{52},38800},{{48},93693},{{38},94682},{{72},17255},{{50},52183},{{62},16763},{{54},64157},{{60},55305},{{58},27985},{{46},54931},{{56},32224},{{64},17374},{{68},12368},{{86},3411},{{66},30960},{{70},17475},{{78},13758},{{76},7253},{{82},4791},{{96},3544},{{112},711},{{100},1923},{{74},8540},{{90},7056},{{84},9818},{{114},1125},{{80},6760},{{88},3454},{{98},1831},{{92},2259},{{106},933},{{94},2058},{{118},433},{{132},301},{{104},1168},{{102},2374},{{110},941},{{126},533},{{120},948},{{148},67},{{108},1634},{{122},287},{{138},210},{{128},183},{{154},43},{{130},211},{{116},439},{{146},46},{{136},100},{{124},318},{{134},128},{{140},140},{{152},52},{{142},90},{{144},123},{{150},94},{{180},10},{{156},57},{{164},20},{{210},4},{{170},18},{{160},27},{{182},5},{{168},25},{{176},11},{{172},4},{{162},27},{{178},12},{{198},6},{{220},1},{{158},19},{{174},10},{{196},1},{{184},4},{{166},9},{{202},2},{{204},3},{{222},1},{{192},3},{{188},1},{{190},1},{{186},3},{{194},1}};

Results

HPm=BarChart[Table[PHK[[b,2]],{b,1,54}],Frame->True,GridLines->Automatic]

Mean, SD and CV, mean log ML and log mean LM, max lik κ

{(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/10000000//N,(Sqrt[(∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/10000000)))^2) PHK[[k,2]]/10000000])//N ,
√((∑_(k=1)^54)(((PHK[[k,1]]-((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/10000000)))^2) PHK[[k,2]]/10000000)/((∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/10000000) //N}

ML= (∑_(k=1)^54)Log[PHK[[k,1]] ] PHK[[k,2]]/10000000//N
LM=Log[(∑_(k=1)^54)PHK[[k,1]]   PHK[[k,2]]/10000000]//N

Plot[Log[κ]-PolyGamma[κ]+ML-LM,{κ,1.,1.7},PlotRange->{-.1,.1}]

Unit mean gamma histogram

gk[κ_,s_]:=(((E^(-s κ)) κ (((s κ))^(-1+κ)))/(Gamma[κ]))
lgampfit=ListPlot[Table[{k+.5,10000000(∫_(8.7713(k-1) /54)^(8.7713k/54))gk[1.56,s]\[DifferentialD]s//Evaluate},{k,1,60}],Frame->True,GridLines->Automatic,PlotStyle->{RGBColor[.1,.07,0],AbsolutePointSize[5]}, PlotRange->All]

Show[HPm,%]