So now we will go away from the mathematical blinds and instead we will try to choose the ideal parameters
of a physically motivated model functions such that some area is minimized.
That sounds a bit cryptic, so let's go to an example.
So we have previously defined the detail, for example, this one that we tried to fit in some way,
and we know already that we have created the data with some polynomial function and some thermal fluctuations,
some random numbers.
And so by just looking at the data, I think it is reasonable that you would assume that this could
be a polynomial function that describes the data.
Also, since it's an odd function, it must be an odd power for the highest power.
And yeah, it looks not so difficult.
So I think it's reasonable to assume that this is a third order polynomial.
But in general, we could say, let's use some polynomial function to fit the data.
So I wrote down that our model function is at the polynomial f of X is a zero plus a one times X to
the power of one plus a two times x two and then more and more terms.
So we can say this is a sum where the index case starts from zero goes to sum end, so maximum value.
And then the terms are just these evolution coefficients a k and then we have these polynomial x to
the power of K.
So for two stars, let us define such a model function in general.
So I will write definition of a polynomial model and we need X and we need support coefficients.
So of course, we could say we defined the coefficients and then just define our polynomials.
We don't put it as an argument here, but we want what we want to try to do is we want to fit these
parameters.
This is the whole purpose of the methods.
So these are the things that we try to change and that we try to optimize.
And therefore it's a very good idea to define the function with the h-he's as the arguments.
And we don't have to define every of these coefficients individually.
We can just define this as an array and this array can be of variable size.
So you see, we can just go ahead now and define or program this sum here.
So as previously, we just say T is zero that we make a loop for K and range O.
We could then say, for example, length of P.
So this means if I were a A-rated, we give for the polynomials has four terms, then this loop will
be run four times and we will then say T will be updated old T plus.
And then we just say use the case elements of the array of eight and multiply it by X to the power of
K.
So this is exactly what's written here.
And then, of course, return the value of T.
And if we now say our starting point for these is will be a zero, which is and three and tier I use
known to the coefficients that we have used for our function from the beginning.
So like minus two two point four minus 0.5 and minus zero point three five, then we can go ahead and
plot this so we can just say T Dot X Label X to Y Label Y and then X list.
So let's redefine the X list.
I think we have overwritten it at some point, so let's just redefine it in space minus five to five.
This is what we have chosen in the beginning and the number of points we called end points.
And then we can finally plot it's plotted or plots x list come out and then purely nominal model of
X list, and then the coefficients will be a zero.
And so then we have plotted here our polynomial.
So we did not plot our data this time.
We just plotted the polynomial.
So ideally, we will start from just some random values of zero because we shouldn't know what these
values are yet.
And then we use our method that we will implement in the following lectures, and then we will update
the values.
At some point, we should hopefully end up with values that are quite similar to these.
And then our function will look very similar to this one so that our data points are described very
well.
And for this, we will continue with the finding an error of function.
So assuming that we do not have the correct values of a yet, then there will be some error.
And first of all, we need a measure for this error.