Lösungen / Statistik 2/07

Remove["Global`*"]

1.

a

<< Statistics`DescriptiveStatistics`

Def.

p[x_, y_] := 1/36;  p[x_] := 1/6;

Sum[p[x, y], {x, 1, 6}, {y, 1, 6}]

fS[x_, y_] := x + y; fP[x_, y_] := x*y;

e[g_, x_, y_] := 
        Sum[g*p[x, y], {x, 1, 6}, {y, 1, 6}];
e[g_, x_] := Sum[g*p[x], {x, 1, 6}];

var[g_, x_] := e[(g - e[g, x])^2, x]; 
    var[g_, x_, y_] := e[(g - e[g, x, y])^2, x, y];

cov[x_, y_] := e[x*y, x, y] - e[x, x]*e[y, y]

corr[x_, y_] := cov[x, y]/Sqrt[var[x, x] var[y, y]]

tab1 = Flatten[Table[fS[x, y], {x, 1, 6}, {y, 1, 6}]]

nTab1 = Length[tab1]

Mittelwerte / Moyennes

{μX = e[x, x], μY = e[y, y]}

μXSY = e[fS[x, y], x, y]

Mean[Flatten[Table[fS[x, y], {x, 1, 6}, {y, 1, 6}]]]

μXPY = e[fP[x, y], x, y]

Mean[Flatten[Table[fP[x, y], {x, 1, 6}, {y, 1, 6}]]]

Varianzen / Variances

varX = e[(x - μX)^2, x]

varY = e[(y - μY)^2, y]

var[x, x]

varXSY = e[(fS[x, y] - μXSY)^2, x, y]

var[fS[x, y], x, y]

varXSYDeskr = 
      Variance[Flatten[Table[fS[x, y], {x, 1, 6}, {y, 1, 6}]]]

varXSYDeskr*(nTab1 - 1) == varXSY*nTab1

varXPY = e[(fP[x, y] - μXPY)^2, x, y]

var[fP[x, y], x, y]

varXPYDeskr = 
      Variance[Flatten[Table[fP[x, y], {x, 1, 6}, {y, 1, 6}]]]

varXPYDeskr*(nTab1 - 1) == varXPY*nTab1

Kovarianz x, y / Covarianc x, y

covXSY = cov[x, y]

varXSY == 2 covXSY + varX + varY

e[(x - μX) (y - μY), x, y]

Korrelation / Corrélation

corr[x, x]

b

Remove["Global`*"]

<< Statistics`DescriptiveStatistics`

Def.

p[x_, y_] := 1/36;  p[x_] := 1/6;

Sum[p[x, y], {x, 1, 6}, {y, 1, 6}]

z1[x_, y_] := x + y; z2[x_, y_] := x*y;

e[g_, x_, y_] := 
        Sum[g*p[x, y], {x, 1, 6}, {y, 1, 6}];
e[g_, x_] := Sum[g*p[x], {x, 1, 6}];

var[g_, x_] := e[(g - e[g, x])^2, x]; 
    var[g_, x_, y_] := e[(g - e[g, x, y])^2, x, y];

covZ1Z2 := 
      e[z1[x, y]*z2[x, y], x, y] - 
        e[z1[x, y], x, y]*e[z2[x, y], x, y]

corr := 
      covZ1Z2/Sqrt[var[z1[x, y], x, y]* var[z2[x, y], x, y]]

tab1 = Flatten[Table[z1[x, y], {x, 1, 6}, {y, 1, 6}]]

tab2 = Flatten[Table[z2[x, y], {x, 1, 6}, {y, 1, 6}]]

nTab1 = Length[tab1]

Mittelwerte / Moyennes

{μZ1 = e[z1[x, y], x, y], μZ2 = e[z2[x, y], x, y]}

μXSY = e[z1[x, y], x, y]

μXPY = e[z2[x, y], x, y]

N[%]

Varianzen / Variances

varZ1 = e[(z1[x, y] - μZ1)^2, x, y]

N[%]

var[z1[x, y], x, y]

N[%]

varZ2 = e[(z2[x, y] - μZ2)^2, x, y]

N[%]

var[z2[x, y], x, y]

N[%]

Kovarianz x, y / Covarianc x, y

covZ1Z2

N[%]

var[z1[x, y] + z2[x, y], x, y] == 
      2 covZ1Z2 + var[z1[x, y], x, y] + var[z2[x, y], x, y]

Korrelation / Corrélation

corr

N[%]

2.

Remove["Global`*"]

<< Statistics`DescriptiveStatistics`

Def.

k = 3;

pX[1] := 1/2; pX[2] = 1/3; pX[3] = 1/6;

    Sum[pX[x], {x, 1, k}]

pY[1] := 1/3; pY[2] = 1/4; pY[3] = 5/12;
Sum[pY[x], {x, 1, k}]

pXY[x_, y_] := 1/12;
pXY[1, 1] := 1/4; pXY[2, 3] := 2/12;
Sum[pXY[x, y], {x, 1, k}, {y, 1, k}]

tab1 = Table[pXY[x, y], {x, 1, k}, {y, 1, k}] // Flatten

fS[x_, y_] := x + y; fP[x_, y_] := x*y;

e[g_, x_, y_] := 
        Sum[g*pXY[x, y], {x, 1, k}, {y, 1, k}];
eX[g_, x_] := Sum[g*pX[x], {x, 1, k}];
eY[g_, y_] := Sum[g*pY[y], {y, 1, k}];

varX[g_, x_] := 
        eX[(g - eX[g, x])^2, x];
varY[g_, y_] := eY[(g - eY[g, y])^2, y]; 
    var[g_, x_, y_] := e[(g - e[g, x, y])^2, x, y];

cov[x_, y_] := e[x*y, x, y] - eX[x, x]*eY[y, y]

corr[x_, y_] := cov[x, y]/Sqrt[varX[x, x]* varY[y, y]]

tab2 = Flatten[Table[fS[x, y], {x, 1, k}, {y, 1, k}]]

nTab2 = Length[tab2]

Mittelwerte / Moyennes

{μX = eX[x, x], μY = eY[y, y]}

μXSY = e[fS[x, y], x, y]

μXPY = e[fP[x, y], x, y]

Varianzen / Variances

vX = eX[(x - μX)^2, x]

vY = eY[(y - μY)^2, y]

vXSY = e[(fS[x, y] - μXSY)^2, x, y]

var[fS[x, y], x, y]

vXPY = e[(fP[x, y] - μXPY)^2, x, y]

var[fP[x, y], x, y]

Kovarianz x, y / Covarianc x, y

covXSY = cov[x, y]

vXSY == 2 covXSY + vX + vY

e[(x - μX) (y - μY), x, y]

Korrelation / Corrélation

corr[x, y]

N[%]

3.

a

Remove["Global`*"]

<< Statistics`LinearRegression`

m = {{1, 1}, {-1, 
            1}, {-1, -1}, {1, -1}};

dPlot = 
        ListPlot[m, PlotStyle -> {PointSize[0.03]}, 
          AspectRatio -> Automatic];

Remove[func]

Fit[m, {1, x}, x]

fu[x_] := Fit[m, {1, x}, x]

fu[x]

Fit[m, {1, x}, x]

fu[x_] = Fit[m, {1, x}, x]

fu[x]

fPlot = 
        Plot[fu[x], {x, -1.5, 1.5}, 
          AspectRatio -> Automatic];

fPlot = 
        Plot[Evaluate[fu[x]], {x, -1.5, 1.5}, 
          AspectRatio -> Automatic];

Show[dPlot, fPlot];

m // MatrixForm

trp = Transpose[m]; trp // MatrixForm

xListe = trp[[1]]

yListe = trp[[2]]

<< Statistics`MultiDescriptiveStatistics`

Correlation[xListe, yListe]

Covariance[xListe, yListe]

b

Remove["Global`*"]

<< Statistics`LinearRegression`

m = {{-1, 0}, {0, 0}, {1, 0}, {2, 0}};

dPlot = 
        ListPlot[m, PlotStyle -> {PointSize[0.03]}, 
          AspectRatio -> Automatic];

Remove[func]

Fit[m, {1, x}, x]

fu[x_] := Fit[m, {1, x}, x]

fu[x]

Fit[m, {1, x}, x]

fu[x_] = Fit[m, {1, x}, x]

fu[x]

fPlot = 
        Plot[fu[x], {x, -1.5, 1.5}, 
          AspectRatio -> Automatic];

fPlot = 
        Plot[Evaluate[fu[x]], {x, -1.5, 1.5}, 
          AspectRatio -> Automatic];

Show[dPlot, fPlot];

m // MatrixForm

trp = Transpose[m]; trp // MatrixForm

xListe = trp[[1]]

yListe = trp[[2]]

<< Statistics`MultiDescriptiveStatistics`

Correlation[xListe, yListe]

Covariance[xListe, yListe]

c

Remove["Global`*"]

<< Statistics`LinearRegression`

m = {{-1, 1}, {0, 1}, {1, 1}, {2, 1}};

dPlot = 
        ListPlot[m, PlotStyle -> {PointSize[0.03]}, 
          AspectRatio -> Automatic];

Remove[func]

Fit[m, {1, x}, x]

fu[x_] := Fit[m, {1, x}, x]

fu[x]

Fit[m, {1, x}, x]

fu[x_] = Fit[m, {1, x}, x]

fu[x]

fPlot = 
        Plot[fu[x], {x, -1.5, 1.5}, 
          AspectRatio -> Automatic];

fPlot = 
        Plot[Evaluate[fu[x]], {x, -1.5, 1.5}, 
          AspectRatio -> Automatic];

Show[dPlot, fPlot];

m // MatrixForm

trp = Transpose[m]; trp // MatrixForm

xListe = trp[[1]]

yListe = trp[[2]]

<< Statistics`MultiDescriptiveStatistics`

Correlation[xListe, yListe]

Covariance[xListe, yListe]

d

Remove["Global`*"]

<< Statistics`LinearRegression`

m = {{0, 1}, {1, 2}, {2, 2.5}, {3, 3}};

dPlot = 
        ListPlot[m, PlotStyle -> {PointSize[0.03]}, 
          AspectRatio -> Automatic];

Remove[func]

Fit[m, {1, x}, x]

fu[x_] := Fit[m, {1, x}, x]

fu[x]

Fit[m, {1, x}, x]

fu[x_] = Fit[m, {1, x}, x]

fu[x]

fPlot = 
        Plot[fu[x], {x, -0.5, 3.5}, 
          AspectRatio -> Automatic];

fPlot = 
        Plot[Evaluate[fu[x]], {x, -0.5, 3.5}, 
          AspectRatio -> Automatic];

Show[dPlot, fPlot];

m // MatrixForm

trp = Transpose[m]; trp // MatrixForm

xListe = trp[[1]]

yListe = trp[[2]]

<< Statistics`MultiDescriptiveStatistics`

Correlation[xListe, yListe]

Covariance[xListe, yListe]

e

Remove["Global`*"]

<< Statistics`LinearRegression`

m = {{0, 1}, {1, 1}, {2, 1.3}, {3, 1}};

dPlot = 
        ListPlot[m, PlotStyle -> {PointSize[0.03]}];

Remove[func]

Fit[m, {1, x}, x]

fu[x_] := Fit[m, {1, x}, x]

fu[x]

Fit[m, {1, x}, x]

fu[x_] = Fit[m, {1, x}, x]

fu[x]

fPlot = Plot[fu[x], {x, -0.5, 3.5}];

fPlot = Plot[Evaluate[fu[x]], {x, -0.5, 3.5}];

Show[dPlot, fPlot];

m // MatrixForm

trp = Transpose[m]; trp // MatrixForm

xListe = trp[[1]]

yListe = trp[[2]]

<< Statistics`MultiDescriptiveStatistics`

Correlation[xListe, yListe]

Covariance[xListe, yListe]