Cap. 4

Exercício 4.6

f[x_,n_,p_]:=PDF[BinomialDistribution[n,p],x];
F[x_,n_,p_]:=CDF[BinomialDistribution[n,p],x];
λ[x_,n_,p_]=((f[x,n,p])/(1-F[x-1,n,p]));

Mean[BinomialDistribution[50,0.05]]
Variance[BinomialDistribution[50,0.05]]

F[14,50,0.05]

list1=Table[{x,N[λ[x,50,0.05],5]},{x,0,10,1}]
ListPlot[list1]

Exercício 4.7

(0.99^4)
1-(((1-0.99))^4)
(0.99^2)
1-(((1-0.99))^3)

Exercício 4.19

λ[t_,μ_,θ_]=θ μ (((μ t))^(θ-1))Exp[(((μ t))^θ)];
Plot[{λ[t,1,.5],λ[t,.5,.6]},{t,.001,10},PlotRange->{0,4},PlotLegends->Placed[{"(μ,θ)=(1,.5)","(μ,θ)=(.5,.6)"},Right]]

Exercício 4.20

f[t_,μ_,σ_]=PDF[LogNormalDistribution[μ,σ],t];
R[t_,μ_,σ_]=1-CDF[LogNormalDistribution[μ,σ],t];
λ[t_,μ_,σ_]=((f[t,μ,σ])/(R[t,μ,σ]));
Plot[λ[t,0,1],{t,0,12},PlotRange->{0,1}]

f[t_,μ_,σ_]=PDF[LogNormalDistribution[μ,σ],t];
R[t_,μ_,σ_]=1-CDF[LogNormalDistribution[μ,σ],t];
h[t_,μ_,σ_]=((f[t,μ,σ])/(R[t,μ,σ]));

Plot[{f[t,0,1],f[t,1,0.3],f[t,2,.3]},{t,0,12},PlotRange->{0,.8},PlotLegends->Placed[{"μ,σ=0,1","μ,σ=1,.3","μ,σ=2,.3"},Right],
PlotStyle->{GrayLevel[0],{GrayLevel[0],Dashing[{.03}]},GrayLevel[.5]}]

Plot[{R[t,0,1],R[t,1,0.3],R[t,2,.3]},{t,0,12},PlotRange->{0,1},AxesOrigin->{0,0},PlotLegends->Placed[{"μ,σ=0,1","μ,σ=1,.3","μ,σ=2,.3"},Right],
PlotStyle->{GrayLevel[0],{GrayLevel[0],Dashing[{.03}]},GrayLevel[.5]}]

Plot[{h[t,0,1],h[t,1,0.3],h[t,2,.3]},{t,0,12},PlotRange->{0,1.8},AxesOrigin->{0,0},PlotLegends->Placed[{"μ,σ=0,1","μ,σ=1,.3","μ,σ=2,.3"},Right],
PlotStyle->{GrayLevel[0],{GrayLevel[0],Dashing[{.03}]},GrayLevel[.5]}]

Exercício 4.22

f[t_,α_,δ_]=PDF[WeibullDistribution[α,δ],t];
R[t_,α_,δ_]=1-CDF[WeibullDistribution[α,δ],t];
h[t_,α_,δ_]=((f[t,α,δ])/(R[t,α,δ]));
Plot[{f[t,0.25,1],f[t,1,1],f[t,2,1],f[t,4,1]},{t,0,5},PlotRange->{0,2},PlotLegends->Placed[{"α=.25","α=1","α=2","α=4"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

Plot[{R[t,0.25,1],R[t,1,1],R[t,2,1],R[t,4,1]},{t,0,2},PlotRange->{0,2},PlotLegends->Placed[{"α=.25","α=1","α=2","α=4"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

Plot[{h[t,0.25,1],h[t,1,1],h[t,2,1],h[t,4,1]},{t,0,2},PlotRange->{0,2},PlotLegends->Placed[{"α=.25","α=1","α=2","α=4"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}e]

Exercício 4.23

amostra={.41,.58,.75,.83,1.,1.08,1.17,1.25,1.35};
n=Dimensions[amostra][[1]]
Mean[amostra]
Variance[amostra]×(n-1)/n+((Mean[amostra])^2)

h=FindRoot[{Mean[amostra]-δ×Gamma[(1/α)+1]==0,
Variance[amostra]×(n-1)/n+((Mean[amostra])^2)-(δ^2)×Gamma[(2/α)+1]==0},{δ,1},{α,1}]
raiz={δ,α}/.Dispatch[h];

FindRoot[{δ-((((((∑_(i=1)^n)(((amostra[[i]]))^α))/n)))^(1/α))==0,
(n/α)-n×Log[δ]+(∑_(i=1)^n)Log[amostra[[i]]]+(δ^(-α))×Log[δ]×(∑_(i=1)^n)(((amostra[[i]]))^α)
-(δ^(-α))×(∑_(i=1)^n)Log[amostra[[i]]](((amostra[[i]]))^α)==0},{δ,raiz[[1]]},{α,raiz[[2]]}]

Exercício 4.25

f[t_,μ_,σ_]=PDF[NormalDistribution[μ,σ],t];
R[t_,μ_,σ_]=1-CDF[NormalDistribution[μ,σ],t];
λ[t_,μ_,σ_]=((f[t,μ,σ])/(R[t,μ,σ]));

Plot[{f[t,.5,.075],f[t,1,.1],f[t,2,.15]},{t,0,3},PlotRange->{0,6},PlotLegends->Placed[{"μ=.5,σ=.075","μ=1,σ=.1","μ=2,σ=.15"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

Plot[{R[t,.5,.075],R[t,1,.1],R[t,2,.15]},{t,0,3},PlotRange->{0,1},PlotLegends->Placed[{"μ=.5,σ=.075","μ=1,σ=.1","μ=2,σ=.15"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

Plot[{λ[t,.5,.075],λ[t,1,.1],λ[t,2,.15]},{t,0,3},PlotRange->{0,6},PlotLegends->Placed[{"μ=.5,σ=.075","μ=1,σ=.1","μ=2,σ=.15"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

Exercício 4.26

f[t_,μ_,σ_]=((PDF[NormalDistribution[μ,σ],((t-μ)/σ)])/(1-CDF[NormalDistribution[μ,σ],((-μ)/σ)]));
R[t_,μ_,σ_]=((1-CDF[NormalDistribution[μ,σ],((t-μ)/σ)])/(1-CDF[NormalDistribution[μ,σ],((-μ)/σ)]));
λ[t_,μ_,σ_]=((f[t,μ,σ])/(R[t,μ,σ]));

Plot[{f[t,.5,.075],f[t,1,.1],f[t,2,.15]},{t,0,3},PlotRange->{0,6},PlotLegends->Placed[{"μ=.5,σ=.075","μ=1,σ=.1","μ=,σ=.15"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

Plot[{R[t,.5,.075],R[t,1,.1],R[t,2,.15]},{t,0,3},PlotRange->{0,1},PlotLegends->Placed[{"μ=.5,.075","μ=1,σ=.1","μ=,σ=15"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

Plot[{λ[t,.5,.075],λ[t,1,.1],λ[t,2,.15]},{t,0,3},PlotRange->{0,6},PlotLegends->Placed[{"μ=.5,σ=.075","μ=1,σ=.1","μ=2,σ=.15"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

λ[t_,μ_,σ_]=(((PDF[NormalDistribution[μ,σ],((t-μ)/σ)])/(1-CDF[NormalDistribution[μ,σ],((-μ)/σ)]))/((1-CDF[NormalDistribution[μ,σ],((t-μ)/σ)])/(1-CDF[NormalDistribution[μ,σ],((-μ)/σ)])));
Plot3D[λ[t,0,σ],{σ,1,2},{t,0.00001,5},PlotPoints->40]

Exercício 4.28

PDF[GammaDistribution[α,(1/λ)],t]

f[t_,λ_,α_]=PDF[GammaDistribution[α,(1/λ)],t];
R[t_,λ_,α_]=1-CDF[GammaDistribution[α,(1/λ)],t];
h[t_,λ_,α_]=((f[t,λ,α])/(R[t,λ,α]));

Plot[{f[t,.5,.5],f[t,5,1],f[t,.25,2],f[t,1,2]},{t,0,5},PlotRange->{0,1},PlotLegends->Placed[{"λ=.5,α=.5","λ=.5,α=1","λ=.25,α=2","λ=1,2α="},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

Plot[{R[t,.5,.5],R[t,.5,1],R[t,.25,2],R[t,1,2]},{t,0,5},PlotRange->{0,1},PlotLegends->Placed[{"λ=5,α=.5","λ=5,α=1","λ=.25,α=2","λ=1,α=2"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

Plot[{h[t,.5,.5],h[t,.5,1],h[t,.25,2],h[t,1,2]},{t,0,5},PlotRange->{0,1.5},PlotLegends->Placed[{"λ=.5,α=.5","λ=.5,α=1","λ=.25,α=2","λ=1,α=2"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

Exercício 4.30

n=50;
α=0.05;

h=FindRoot[{
PDF[ChiSquareDistribution[2×n],a]-PDF[ChiSquareDistribution[2×n],b]==0,
(CDF[ChiSquareDistribution[2×n],b]-CDF[ChiSquareDistribution[2×n],a])-(1-α)==0},{a,Quantile[ChiSquareDistribution[2×n],(α/2)]},{b,Quantile[ChiSquareDistribution[2×n],1-(α/2)]}]
raiz={a,b}/.Dispatch[h];

((raiz[[1]]×1.89)/(2×n))
((raiz[[2]]×1.89)/(2×n))

raiz[[2]]-raiz[[1]]
Quantile[ChiSquareDistribution[2×n],1-(α/2)]-Quantile[ChiSquareDistribution[2×n],(α/2)]

Exercício 4.32

data={152.7,172.0,172.5,173.3,193.0,204.7,216.5,239.9,262.6,422.6};
n=Dimensions[data][[1]]
miuinic=Mean[data]
lambdainic=((((Mean[data]))^3)/(Variance[data]×(n-1)/n))

h=FindRoot[{
(n/(2lambda))-(1/(2 (miu^2)))(∑_(i=1)^n)((((data[[i]]-miu))^2)/(data[[i]]))==0,
(lambda/(miu^3))(∑_(i=1)^n)((((data[[i]]-miu))^2)/(data[[i]]))+(lambda/(miu^2))(∑_(i=1)^n)(((data[[i]]-miu))/(data[[i]]))==0},{miu,miuinic},{lambda,lambdainic}]

f[t_,μ_,λ_]:=(Sqrt[(λ/(2×π×(t^3)))])Exp[-((λ (((t-μ))^2))/(2 (μ^2)t))];
R[t_,μ_,λ_]:=CDF[NormalDistribution[0,1],(Sqrt[(λ/t)])(1-(t/μ))]-Exp[((2 λ)/μ)]×CDF[NormalDistribution[0,1],-(Sqrt[(λ/t)])(1+(t/μ))];
h[t_,μ_,λ_]:=((f[t,μ,λ])/(R[t,μ,λ]));

Plot[{f[t,1,.5],f[t,1,1],f[t,1,3],f[t,1,10]},{t,0,5},PlotLegends->Placed[{"λ=.5","λ=1","λ=3","λ=10"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}},PlotRange->{{0,5},{0,1.5}}]

Plot[{R[t,1,.5],R[t,1,1],R[t,1,3],R[t,1,10]},{t,0,5},PlotLegends->Placed[{"λ=.5","λ=1","λ=3","λ=10"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]

Plot[{h[t,1,.5],h[t,1,1],h[t,1,3],h[t,1,10]},{t,0,5},PlotLegends->Placed[{"λ=.5","λ=1","λ=3","λ=10"},Right],
PlotStyle->{GrayLevel[0],{RGBColor[1,0,0],Dashing[{.03}]},RGBColor[0,1,0],{RGBColor[0,0,1],Dashing[{.03}]}}]