Intervaly spolahlivosti

Nahrame kniznicne programy, vypocitame priklady z prednasok

<<  Statistics`ContinuousDistributions`

<< Statistics`ConfidenceIntervals`

Spocitame najprv podla  postupu z prednasok

Interval spolahlivosti pre μ a zname σ

Pr1.

Zo zakladneho suboru so znamym rozptylom (σ^2) = 
      20.28  
sme urobili nahodny vyber s nasledujucim vysledkom ... 
Vypocitajte 95  % interval spolahlivosti pre μ
Vypoctajte 90  % IS lavostranny a pravostranny pre μ

data = {51.3,  62.8,  51.9,  57,  55.3,  52.1,  58.4}

aritpriem = Mean[data]

sigma = (Sqrt[20.28])

n = Length[data]

kvantil = Quantile[NormalDistribution[0, 1], 0.975]

lstrana = aritpriem - ((kvantil*sigma)/(Sqrt[n]))

pstrana = aritpriem + ((kvantil*sigma)/(Sqrt[n]))

95% IS pre μ a zname σ je (52.2; 58.87)

kvantil09 = Quantile[NormalDistribution[0, 1], 0.9]

lstrana09 = aritpriem - ((kvantil09*sigma)/(Sqrt[n]))

pstrana09 = aritpriem + ((kvantil09*sigma)/(Sqrt[n]))

90% lavostranny IS  pre μ a zname σ je (53.36;∞)
90% pravostranny ISpre μ a zname σ je (-∞;57.72)

Teraz to iste spocitame pomocou prikazov systemu Mathematica

Poznamka:  default value(prednastavena hodnota) pre IS obojstranne je 95%(α=0.05), navyse ak chcem robit jednostranne IS a procedura si alfu poli, musim zadat do Confidence Level hodnotu 1-2α, pravostranny dostanem tak, ze LS nahradim -∞, lavostranny zase tak, ze PS nahradim ∞

MeanCI[data, KnownVariance -> 20.28]

MeanCI[data, KnownVariance -> 20.28, 
      ConfidenceLevel -> 0.9]

MeanCI[data, KnownVariance -> 20.28, 
      ConfidenceLevel -> 0.8]

Teda LS=(53.36;∞), PS=(-∞;57.72)

Interval spolahlivosti pre μ a nezname σ

Pr2.

\(Zo\ zakladneho\ suboru\ s\ neznamym\ rozptylom\ \ \ sme\ urobili\ nahodny\ vyber\ s\ nasledujucim\ vysledkom ... \)
Vypocitajte 95  % interval spolahlivosti pre μ
Vypoctajte 90  % IS lavostranny a pravostranny pre μ

Pouzijeme kvantily Studentovho t-rozdelenia s n-1 stupnami volnosti,inak sa postup nemeni

kvantilT0975 = Quantile[StudentTDistribution[n - 1], 0.975]

lstrana = 
      aritpriem - ((kvantilT0975*StandardDeviation[data])/(Sqrt[n]))

pstrana = 
      aritpriem + ((kvantilT0975*StandardDeviation[data])/(Sqrt[n]))

95% IS pre μ a nezname σ je (51.65;59.43)

kvantilT09 = Quantile[StudentTDistribution[n - 1], 0.9]

lstrana09 = 
      aritpriem - ((kvantilT09*StandardDeviation[data])/(Sqrt[n]))

pstrana09 = 
      aritpriem + ((kvantilT09*StandardDeviation[data])/(Sqrt[n]))

90% lavostranny IS  pre μ a nezname σ je (53.25;∞)
90% pravostranny ISpre μ a zname σ je (-∞;57.83)

Pomocou systemu Mathematica

MeanCI[data]

MeanCI[data, ConfidenceLevel -> 0.8]

Na zaver vykreslime niekolko hustot Studentovho Trozdelenia s roznymi stupnami volnosti a porovname s normalnym normovanym rozdelenim

ndgraf = 
      Plot[PDF[NormalDistribution[0, 1], t], {t, -3, 3}, 
        PlotStyle -> {Hue[0.1], Thickness[0.01]}, 
        Axes -> {Automatic, None}]

densityT[x_, st_]  :=  
      PDF[StudentTDistribution[st],  x]

Do[g[i] = 
        Plot[densityT[t, i], {t, -3, 3}, PlotRange -> All, 
          Axes -> {Automatic, None}], {i, 1, 5}]

Show[ndgraf, Table[g[i], {i, 1, 5}]]

Interval spolahlivosti pre nezname σ,(σ^2)

Pr3.

\(Zo\ zakladneho\ suboru\ s\ neznamym\ rozptylom\ \ \ sme\ urobili\ nahodny\ vyber\ s\ nasledujucim\ vysledkom ... \)
Vypocitajte 95  % interval spolahlivosti pre σ
Vypoctajte 90  % IS lavostranny a pravostranny pre σ

kvantilCHI0975 = 
      Quantile[ChiSquareDistribution[n - 1], 0.975]

kvantilCHI0025 = 
      Quantile[ChiSquareDistribution[n - 1], 0.025]

lstrana = (((n - 1)*Variance[data])/kvantilCHI0975)

pstrana = (((n - 1)*Variance[data])/kvantilCHI0025)

95% IS pre (σ^2)  (7.34; 85.77)

kvantilCHI09 = Quantile[ChiSquareDistribution[n - 1], 0.9]

kvantilCHI01 = Quantile[ChiSquareDistribution[n - 1], 0.1]

lstrana = (((n - 1)*Variance[data])/kvantilCHI09)

pstrana = (((n - 1)*Variance[data])/kvantilCHI01)

90% lavostranny IS  pre μ a nezname (σ^2) je (9.97; ∞)
90% pravostranny ISpre μ a zname σ je (0; 48.15)

Teraz pomocou systemu Mathematica

VarianceCI[data]

VarianceCI[data, ConfidenceLevel -> 0.8]

Na zaver vykreslime zopar hustot CHi rozdelenia s roznymi stupnami volnosti

densityCH[x_, st_]  :=  
      PDF[ChiSquareDistribution[st],  x]

Do[g[i] = 
        Plot[densityCH[t, i*10], {t, 0, 80}, PlotRange -> All, 
          Axes -> {Automatic, None}], {i, 1, 5}]

Show[Table[g[i], {i, 1, 5}]]