Lösungen / Statistik 2/04

Remove["Global`*"]

1.

q = 1 - p;
z[x_, n_, p_] := (x - n p)/Sqrt[n p (1 - p)]; 
    f[x_, n_, p_] := 
      Binomial[n, x] p^
          x (1 - p)^(n - x);
φ[z_, n_, p_] := 
        1/Sqrt[2 Pi n p (1 - p)] E^(-z^2/
                2);
showPlot[n_, p_, h_] := 
        Show[Plot[φ[z[x, n, p], n, p], {x, 0, n}, 
            PlotRange -> {0, h}], 
          ListPlot[Table[{x, f[x, n, p]}, {x, 0, n}], 
            PlotStyle -> {PointSize[0.03]}, 
            PlotRange -> {0, h}]  ];
showPlot[5, 0.5, 0.5];

showPlot[10, 0.5, 0.3];

showPlot[100, 0.5, 0.1];

showPlot[1000, 0.5, 0.03];

2.

Remove["Global`@*"]

<< Statistics`DataManipulation`

?Random

randListe[n_] := {Table[Random[Integer, {1, 6}], {i, 1, n}], 
          m = n};
rL = randListe[1000]

freq = Frequencies[rL[[1]]]

tab = Table[freq[[n]][[1]], {n, 1, 6}]

{n, m}

diff = Abs[Table[tab[[n]]/m - 1/6, {n, 1, 6}]] // N

rL = randListe[100000];
freq = Frequencies[rL[[1]]];
tab = 
        Table[freq[[n]][[1]], {n, 1, 
            6}];
diff = Abs[Table[tab[[n]]/m - 1/6, {n, 1, 6}]] // N

3.

Remove["Global`@*"]

?Log

φ1[t_, μ_, σ_] := 
        1/(σ Sqrt[
                  2 Pi]) E^(-(t - μ)^2/(2 σ^2));

    
h[x_ /; x ≤ 0, a_, μ_, σ_] := 0; 
    h[x_ /; x > 0, a_, μ_, σ_] := 
      Log[a, E]/x *  φ1[Log[a, x], μ, σ];

Plot[φ1[t, 5, 2], {t, -5, 15}];

?h

h[x, 7, 5, 2]

h[3, 10, 5, 2] // Evaluate

h[3, 10, 0, 2] // Evaluate

h[0.000001, 10, 0, 1]

h[0.00000000000000000001, 10, 0, 2]

Plot[h[x, 10, 0, 0.5], {x, -3, 3}];

Plot[h[x, E, 0, 1], {x, -3, 6}];

hH[x_, a_, μ_, σ_] := 
        Integrate[
          Evaluate[h[t, a, μ, σ]], {t, 0, x}];

Plot[hH[x, 10, 0, 1], {x, 0, 10}];

4.

Remove["Global`@*"]

f[x_ /; x < 0, α_] := 0;
f[
          x_ /; x ≥ 
              0, α_] := α E^(-α x);

    
Plot[f[x, 1], {x, -1, 6}, 
        PlotRange -> {0, 1}];

Plot[f[x, 2], {x, -1, 2}, PlotRange -> {0, 2}];

5.

Remove["Global`@*"]

f[x_, a_, b_, c_ /; x ≤  c] := 0; 
    f[x_, a_, b_, c_ /; x > c] := 
      b/a ((x - c)/a)^(b - 
              1) E^(-((x - c)/a)^
                b)

    
Plot[f[x, 1, 1/2, 0], {x, -1, 6}, 
        PlotRange -> {0, 1}];

Plot[f[x, 1, 1, 0], {x, -1, 6}, 
        PlotRange -> {0, 1}];

Plot[f[x, 1, 2, 0], {x, -1, 6}, 
        PlotRange -> {0, 1}];

Plot[f[x, 1, 4, 0], {x, -1, 6}, 
        PlotRange -> {0, 2}];

Plot[f[x, 2, 4, 0], {x, -1, 6}, 
        PlotRange -> {0, 2}];

Plot[f[x, 2, 4, 1], {x, -1, 6}, 
        PlotRange -> {0, 2}];

6.

Remove["Global`@*"]

f[x_ /; x ≤  0, b_, p_] := 0; 
    f[x_ /; x >  0, b_, p_] := 
      b^p/Gamma[p] x^(p - 1) E^(-b x);

Plot[f[x, 0.5, 1], {x, -1, 6}, 
        PlotRange -> {0, 1}];

Plot[f[x, 1, 1], {x, -1, 6}, 
        PlotRange -> {0, 1}];

Plot[f[x, 1, 0.5], {x, -1, 6}, 
        PlotRange -> {0, 1}];

Plot[f[x, 1, 2], {x, -1, 6}, 
        PlotRange -> {0, 0.5}];

Plot[f[x, 1, 4], {x, -1, 10}, 
        PlotRange -> {0, 0.5}];

7.

Remove["Global`*"]

points = {{0, 2}, {1, 1}, {2, 2}, {3, 1}, {4, 2}, {5, 
            3}};

a

f1 = FindFit[points, a + b x, {a, b}, x]

fg1[x_] := a + b x /. f1;    fg1[x]

plotpoints = 
        ListPlot[points, PlotStyle -> PointSize[0.02],  
          AspectRatio -> Automatic];

pl1 = 
        Plot[fg1[x], {x, -1, 6},  
          AspectRatio -> Automatic];

Show[pl1, plotpoints,  AspectRatio -> Automatic];

b

points // MatrixForm

trp = Transpose[points]; trp // MatrixForm

xListe = trp[[1]]

yListe = trp[[2]]

<< Statistics`MultiDescriptiveStatistics`

Correlation[xListe, yListe]

N[%]

Covariance[xListe, yListe]

N[%]

c

points // MatrixForm

pointsT = {Transpose[points][[2]], Transpose[
                points][[1]]} // 
          Transpose;
pointsT // MatrixForm

f2 = FindFit[pointsT, c + d x, {c, d}, x]

fg2[x_] := c + d x /. f2;    fg2[x]

plotpoints1 = 
        ListPlot[pointsT, PlotStyle -> PointSize[0.02],  
          AspectRatio -> Automatic];

pl2 = 
        Plot[fg2[x], {x, -1, 4},  
          AspectRatio -> Automatic];

Show[pl2, plotpoints1,  AspectRatio -> Automatic];

d

Ueberhaupt nicht senkrecht!

8.

M1 = {{0.0, 0.0}, {0.1, 1.0}, {1.0, 0.0}, {0.9, 
            1.1}};
M2 = {{0.0, 0.0}, {1.0, 0.1}, {2.0, -0.1}, {3.0, 
            0.0}};

a

M1 // MatrixForm

trp1 = Transpose[M1]; trp1 // MatrixForm

xListe1 = trp1[[1]]

yListe1 = trp1[[2]]

<< Statistics`MultiDescriptiveStatistics`

Correlation[xListe1, yListe1]

Covariance[xListe1, yListe1]

b

M2 // MatrixForm

trp2 = Transpose[M2]; trp2 // MatrixForm

xListe2 = trp2[[1]]

yListe2 = trp2[[2]]

<< Statistics`MultiDescriptiveStatistics`

Correlation[xListe2, yListe2]

Covariance[xListe2, yListe2]

c

Schwache Korrelation