Lösungen/Solutions/F2S2Ue/Ex02

L = Lektion/ Leçon   -- Sprechstunde / heures de consultation
W = Work / Arbeit / Travail
A=Anhang/Annexe/Appendice

Ueb/Ex 1      W

Remove["Global`@*"]

<< Statistics`DiscreteDistributions`

bdist[n_] := BinomialDistribution[n, 1/6]

pdf[n_, x_] := PDF[bdist[n], x];
cdf[n_, x_] := CDF[bdist[n], x];

lpPDF[n_] := 
        ListPlot[Table[{x, pdf[n, x]}, {x, 0, n}], 
          PlotStyle -> {PointSize[0.03]}];
lpCDF[n_] := 
        ListPlot[Table[{x, cdf[n, x]}, {x, 0, n}], 
          PlotStyle -> {PointSize[0.03]}];

Table[lpPDF[n], {n, 1, 20}];

Table[lpCDF[n], {n, 1, 20}];

Ueb/Ex 2      W

p = 0.002;  μ[n_] :=  n* p; 
f[x_, n_] := (μ[n]^x)/(x!)* 
        E^(-μ[n])

Plot[f[x, 100], {x, 0, 2}];

f[0, 100]

f[0, 1000]

Plot[f[0, n], {n, 0, 5}];

Plot[f[0, n], {n, 0, 2000}];

pD100[x_] := PDF[PoissonDistribution[μ[100]], x]

{pD100[0], f[0, 100]}

{pD100[3], f[3, 100]}

Table[{k, pD100[k]}, {k, 0, 5}]

g1 = 
        ListPlot[Evaluate[Table[{k, pD100[k]}, {k, 0, 5}]], 
          PlotStyle -> {PointSize[0.03]}];

g2 = 
        Plot[f[x, 100], {x, 0, 5}, PlotRange -> {0, 1}];

Plot[f[x, 100], {x, 0, 5}, PlotRange -> {0, 1}, 
        Epilog -> {PointSize[0.03], 
            Map[Point, Table[{k, pD100[k]}, {k, 0, 5}]]}];

Ueb/Ex 3      W

a

n = 2000; p = 1/365;   μ[n_] :=  n* p;  
    f[x_, n_] := (μ[n]^x)/(x!)* 
        E^(-μ[n]);
Plot[f[x, n], {x, 0, 15}];

Table[f[x, n], {x, 0, 15}] // N

f[2, n] // N

b

1 - f[1, n] - f[0, n] // N

Ueb/Ex 4      W

t1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
          13};
t = {57, 203, 383, 525, 532, 408, 273, 139, 45, 27, 10, 4, 2, 
        0}

t2 = Transpose[{t1, t}]

s = Apply[Plus, t]

μ4 = 
      Sum[t1[[k]] t[[k]], {k, 1, Length[t]}]/s  // N

f4[x_] := (μ4^x)/(x!)* 
          E^(-μ4);

Plot[f4[x], {x, 0, 15}];

t3 = t/s

t4 = Transpose[{t1, t3}] // N

Plot[f4[x], {x, 0, 15}, 
        Epilog -> {PointSize[0.03], Map[Point, t4]}];

Ueb/Ex 5      W

f5[Nn_, M_, n_, x_] := 
      Binomial[M, x] Binomial[Nn - M, n - x]/Binomial[Nn, n]

Table[f5[11 + 3, 11, 4, x], {x, 0, 4}] // N

Ueb/Ex 6      W

Nn = 1000; M = 20; n = 100; p = M/Nn;

bdist[n_, p_] := 
        BinomialDistribution[n, p];
pdf[n_, x_, p_] := PDF[bdist[n, p], x];

ListPlot[Table[{x, pdf[n, x, p]}, {x, 0, n}], 
        PlotStyle -> {PointSize[0.03]}];

p1 = 
        ListPlot[Table[{x, pdf[n, x, p]}, {x, 0, 10}], 
          PlotStyle -> {PointSize[0.03]}];

ListPlot[Table[{x, f5[Nn, M, n, x]}, {x, 0, 10}], 
        PlotStyle -> {PointSize[0.03]}];

p2 = 
        ListPlot[Table[{x, pdf[n, x, p] - f5[Nn, M, n, x]}, {x, 0, 10}], 
          PlotStyle -> {PointSize[0.03]}];

Show[p1, p2];

Ueb/Ex 7      W

Nn = 100; M = 100*0.1; n = 10;

f5[Nn, M, n, 0] // N

1 - f5[Nn, M, n, 0] // N

1 - f5[Nn, 100*(0.1 - 0.01), n, 0] // N

1 - f5[Nn, 100*(0.1 - 0.05), n, 0] // N

1 - f5[Nn, 100*(0), n, 0] // N

Plot[1 - f5[Nn, k, n, 0], {k, 0, M}];