Sin[Pi]

data=Drop[Import["http://braeburn.pha.jhu.edu/~ariess/R06/sn_sample","Table"],17];

First[data]

snIa=Select[Drop[data,1],#[[5]]=="Gold"&];

num=Dimensions[snIa][[1]]

μ==5 Log[10,dL]+25

Solve[%,dL]

Needs["ErrorBarPlots`"]

p=Table[{{snIa[[ii,2]],(10^(-5+((snIa[[ii,3]])/5)))},ErrorBar[ 1/2((10^(-5+((snIa[[ii,3]]+snIa[[ii,4]])/5)))-(10^(-5+((snIa[[ii,3]]-snIa[[ii,4]])/5))))]},{ii,1,num}];

zdL=Table[{snIa[[ii,2]],(10^(-5+((snIa[[ii,3]])/5)))},{ii,1,num}];

riess=ErrorListPlot[p,PlotRange->All,AxesLabel->{"z","(Subscript[d, L]) [Mpc]"}]

Plot[{299792.458/43.5 z,299792.458/71 z,,299792.458/58.2 z},{z,0,2}]

Show[%,riess,AxesLabel->{"z","(Subscript[d, L]) [Mpc]"}]

(* Export["Riess_gold.pdf",%]*)

weights = Table[1/Sqrt[1/2((10^(-5+((snIa[[ii,3]]+snIa[[ii,4]])/5)))-(10^(-5+((snIa[[ii,3]]-snIa[[ii,4]])/5))))],{ii,1,num}];

dL[z_,Ωm_,Ωλ_,H0_]:=Piecewise[{{Re[299792.458/H0(1+z)/Sqrt[1-Ωm-Ωλ]Sinh[Sqrt[1-Ωm-Ωλ] NIntegrate[1/Sqrt[(1+zz)^2(1+ Ωm zz)-zz(zz+2)Ωλ],{zz,0,z}] ]],Ωm+Ωλ<1},{Re[299792.458/H0(1+z)NIntegrate[1/Sqrt[(1+zz)^2(1+ Ωm zz)-zz(zz+2)Ωλ],{zz,0,z}] ],Ωm+Ωλ==1},{Re[299792.458/H0(1+z)/Sqrt[1-Ωm-Ωλ]Sin[Sqrt[1-Ωm-Ωλ] NIntegrate[1/Sqrt[(1+zz)^2(1+ Ωm zz)-zz(zz+2)Ωλ],{zz,0,z}] ]],Ωm+Ωλ>1}}]

dL[1,0.3,0.7,1]

Manipulate[Show[Plot[dL[z,Ωm,Ωλ,Hubble],{z,0,2},PlotRange->{{0,2},{0,20000}}],riess],{{Ωm,0.3},0,2},{{Ωλ,0.7},-1,2},{ {Hubble,65},50,100,2}]

zdL //Short

Select[zdL,#[[1]]<0.2&]

FindFit[%,299792.458/H0  z,{H0},z]

Ωm1=0.1
Ωm2=1.2
Ωλ1=0.05
Ωλ2=2.0
H01=40
H02=90

cosmo = Interpolation [Flatten[Table[{{z,Ωm,Ωλ,H0},dL[z,Ωm,Ωλ,H0]},{z,0.001,2,0.1},{Ωm,Ωm1,Ωm2,0.2},{Ωλ,Ωλ1,Ωλ2,0.2},{H0,H01,H02,10}],3] ,InterpolationOrder->3]

Needs["NonlinearRegression`"]

NonlinearRegress[zdL,299792.459/H0 z,{{H0,71}},z]

NonlinearRegress[zdL,cosmo[z,Ωm,1-Ωm,H0],{{Ωm,0.3},{H0,71}},z,Weights->weights]

Show[riess,Plot[cosmo[z,0.6,0.4,57.4],{z,0,2}]]

NonlinearRegress[zdL,cosmo[z,Ωm,Ωλ,H0],{{Ωm,0.3},{Ωλ,0.7},{H0,71}},z,Weights->weights]

var[Ωm_,Ωλ_,H0_]:=Sum[(dL[zdL[[ii,1]],Ωm,Ωλ,H0]-zdL[[ii,2]])^2,{ii,1,num}];