dh-Materialien
Maple   
Übungen

Nichtlineare Regression

> restart;
  with(stats): with(statplots): with(fit): with(plots):
  Seed:= randomize():
  interface(displayprecision = 3):
  opts:= 'font = [Courier, 12],
          size = [350, 300]':

Simulation der Messung einer Größe y in Abhängigkeit von x:

> xWerte:= [seq(n/5, n = 0..20)]:
f:= x -> -x^2 + 4*x + 1;
yWerte:= map(x -> f(x) + (rand(90)() - 45)/70, xWerte):

> scatterplot (xWerte, yWerte, opts,
  color  = black,
  symbol = cross,
  labels = ["x", "y"]);

nlinregr2 

Finden einer Regressionskurve mit der Methode der kleinsten Quadrate:

> Punkte:= scatterplot(xWerte, yWerte,
  color  = black,
  symbol = cross,
  labels = ["x", "y"]):
lsq:= leastsquare[[x,y], y = a*x^2 + b*x + c,
                 {a, b, c}]([xWerte, yWerte]):
y:= rhs(lsq);

nlinregr3 

> regr(x):= evalf(y, 3);
Regressionskurve:= plot(regr(x), x = 0..4,
  opts,
  color = red):
Kurve:= plot(f(x), x = 0..4,
  color = blue,
  linestyle = DOT):
display([Punkte, Kurve, Regressionskurve]);

nlinregr5