(* Import["http://braeburn.pha.jhu.edu/~ariess/R06/Davis07_R07_WV07.dat"] *)
(*Import["http://supernova.lbl.gov/Union/figures/SCPUnion_mu_vs_z.txt"];*)
Import["C:/SCPUnion_mu_vs_z.txt"];
Short[%,20]

sn= Drop[Import["C:/SCPUnion_mu_vs_z.txt","Table"] ,4] ;

zm={Transpose[sn][[2]],Transpose[sn][[3]]}//Transpose;

dL3[Ωm_?NumberQ,Ωλ_?NumberQ,H0_?NumberQ]:=(dL3[Ωm,Ωλ,H0]=Interpolation[Table[{z,Piecewise[{{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},{299792.458/H0(1+z)NIntegrate[1/Sqrt[(1+zz)^2(1+ Ωm zz)-zz(zz+2)Ωλ],{zz,0,z}] ,Ωm+Ωλ==1},{299792.458/H0(1+z)/Sqrt[Ωm+Ωλ-1]Sin[Sqrt[Ωm+Ωλ-1] NIntegrate[1/Sqrt[(1+zz)^2(1+ Ωm zz)-zz(zz+2)Ωλ],{zz,0,z}] ],Ωm+Ωλ>1}}]},{z,0,3,0.25}]])

num=Dimensions[zm][[1]]

zdL=Table[{zm[[ii,1]],(10^(-5+(m/5)))/.m->zm[[ii,2]]},{ii,1,num}]//Sort;

z0=zdL[[1]] //First(* najniższe z *)

z1=zdL //Last //First(* najwyższe z *)

Needs["ErrorBarPlots`"]

err=Table[((2^(-5+((sn[[ii,3]])/5))) (5^(-6+((sn[[ii,3]])/5))) Log[10])*sn[[ii,4]],{ii,1,num}];

zdLerr=Table[{{zdL[[ii,1]],zdL[[ii,2]]},ErrorBar[err[[ii]]]},{ii,1,num}];

model1=NonlinearModelFit[zdL,dL3[OmegaM,OmegaΛ,Hubble][z],{{OmegaM,0.3},{OmegaΛ,0.8},{Hubble,50}},z]  ;

model1["ParameterTable"]

model2=NonlinearModelFit[zdL,dL3[OmegaM,OmegaΛ,68][z],{{OmegaM,0.3},{OmegaΛ,0.8}},z]  ;

model2["ParameterTable"]

model3=NonlinearModelFit[zdL,dL3[1-OmegaΛ,OmegaΛ,72][z],{{OmegaΛ,0.8}},z] ;

model3["ParameterTable"]

model3["BestFitParameters"]

model4=NonlinearModelFit[zdL,dL3[0,0,H][z],{{H,50}},z] ;

model4["ParameterTable"]

m1=Plot[Tooltip[dL3[OmegaM,OmegaΛ,Hubble][z]/.model1["BestFitParameters"],model1["ParameterTable"]],{z,0,2},PlotStyle->Red];

m2=Plot[Tooltip[dL3[OmegaM,OmegaΛ,68][z]/.model2["BestFitParameters"],model2["ParameterTable"]],{z,0,2},PlotStyle->Blue];

m3=Plot[Tooltip[dL3[1-OmegaΛ,OmegaΛ,68][z]/.model3["BestFitParameters"],model3["ParameterTable"]],{z,0,2},PlotStyle->Black];

Show[ErrorListPlot[zdLerr],m1,m2,m3]

Manipulate[Show[ErrorListPlot[zdLerr],Plot[dL3[OmegaM,OmegaΛ,Hubble][z],{z,0,2}]],{Hubble,40,90,2},{{OmegaM,1.0},0,2,0.1},{{OmegaΛ,0},-2,2,0.2},ControlPlacement->{Right}]