ClearAll;Clear[f1];Clear[f2];
$DefaultFont = {"Times-Roman",10};
Needs["Statistics`DataManipulation`"];
Needs["Graphics`Graphics`"];
cumulative = {312/545,413/545,487/545,522/545,537/545,1};
datapoints = {{0,0},{1,312/545},{2,413/545},
			  {3,487/545},{4,522/545},{5,537/545},{6,1}};
density = {312/545,101/545,74/545,35/545,15/545,8/545};
F1[A_,th_,c_,t_] = (3 th + (th + 2)A)t/(2(th+1)c) - A(t/c)^2 + ((-th + (th+2)A)/(2(th+3))) (t/c)^3;
F2[A_,th_,c_,t_] = 1 - ((3-A)/((3+th)(1+th))) (c/t)^th;
f1[A_,th_,c_,t_] = (3 th + (th + 2)A)/(2(th+1)c) - 2A t/(c^2) + 3((-th + (th+2)A)/(2c(th+3))) (t/c)^2;
f2[A_,th_,c_,t_] = (th(3-A)/((3+th)(1+th)c)) (c/t)^(th+1);

FF[A_,th_,c_,t_] = Which[t<=2,F1[A,th,c,t],t>2,F2[A,th,c,t]];

error[A_,th_,c_] = Apply[Plus,Table[(FF[A,th,c,n]-cumulative[[n]])^2,{n,1,6}]];
leasterror = FindMinimum[error[A,th,c],{A,2,2.01,0,4},{th,2,2.01,0,4},{c,2,2.01,0,4}];
Aopt = A/.leasterror[[2]]
thopt = th/.leasterror[[2]]
copt = c/.leasterror[[2]]
F[t_] = Which[t<=copt,F1[Aopt,thopt,copt,t],t>copt,F2[Aopt,thopt,copt,t]];
f[t_] = Which[t<=copt,f1[Aopt,thopt,copt,t],t>copt,f2[Aopt,thopt,copt,t]];
Print["Error is ",leasterror[[1]]];

up:= Show[Plot[f[t],{t,0.001,6}],
			PlotRange->{{0,6.05},{0,0.8}},
			PlotLabel->FontForm["(a)  y = F'(t) = f(t)\n        (p.d.f.)",
				{"Courier",10}],
			AxesOrigin->{-0.15,-0.025},
			Axes->True,AxesLabel->{" t","y"}];
			
down:= Show[Plot[F[t],{t,0.001,6},
			PlotRange->{{0,6.05},{0,1.05}},
			PlotLabel->FontForm["(b)  y = F(t)\n     (c.d.f.)",{"Courier",10}],
			AxesOrigin->{-0.15,-0.025},
			Axes->True,AxesLabel->{" t","y"}],
			ListPlot[datapoints]];
Show[GraphicsArray[{{up},{down}}],
		PlotLabel->"       Figure 27.2\nPrairie dog survival"]