So in the previous lecture, we have seen that a cube explained function that's that is defined piece
wise works very well for describing these data points.
So the general trend of the data points is nicely reproduced by this function.
And the good thing is that now we have the function that describes the trend of the data between the
data points.
So for example, if we want to calculate now some derivative at this point, we do not have to use these
and these two points as the reference.
But we can just take some small area near the point to calculate the derivative so it can be very,
very helpful and it makes the life a lot easier.
So these cubic lines, they work well and they have a continuous derivative at the data points.
But so far, the data was very smooth, so it wasn't so difficult to generate this interpolation.
So let's see what happens if we used to perturb data from here.
So I will scroll down where we have left our notebook and now we come to the perturb data.
And this time I will just basically copy what we had written down here, and then I will just paste
it at the bottom where we have left.
And this time I will write spline Kubik without the zero, because this time we will fit not the zero
data, but the actual data.
And of course, we will use a cubic methods.
So now we use here once again such an ex list that we have to find previously, so we don't have to
redefine it again.
We can just write here ex list.
And
no, sorry, that was not correct.
I wanted to change the other one.
So this one or two data points, we leave them as they are, and then we just changed this plot.
Exactly.
So we use X list and then Blind Cubic X list.
And then we can run it, and we see, OK, Rick's list is defined in an odd way, so we have to change
it.
So let me change it.
Maybe let's go from minus four point five to four point five with nine hundred and one points so that
it looks like this.
So now you may wonder what is going on here.
It looks a bit odd.
Um, so I think, yeah, this is because we plot here the the unperturbed data and not the perturbed
ones.
So maybe let me do it like this.
I will write your plot.
So then now blue is the actual data.
Orange is the blind fit of the new data, and I will know the plot, the new data as well.
So let me do it like this and I will do it in a scatterplot.
Yes, exactly.
Now it looks good.
So we have in blue the unperturbed data we have in the blue dots, the perturb data, and we have an
orange, the cubic blind fitting the perturbed data.
And do you see, as I mentioned earlier, every individual data point is really fitted, which can be
good, but actually we call this in numeric that it is over fitted.
So of course, if you think of it in terms of physics, then the physical dependence on a physical model
behind it will, of course, never be so difficult here.
It will not have all of these fluctuations.
It's pretty, pretty clear that this is just noise.
So what we would want here is we want to smooth these blind and we don't want every point to be fitted
perfectly.
And to do this, we will come to new methods in the next lecture, which is called We are fitting a
model function.
But I want to show you here that is.
It is also possible with slides.
However, we must use a different command this time.
It's called interpolate and then it's called uni variance on line, and we must fit data zero and data
one.
And this time we don't use an optional argument.
It works just as it is.
And I recall this function supplying smooth.
And let's see, maybe I have a typo.
Yeah, here of a typo.
Um, you need very splain.
Maybe still a typo.
You need to vary it with an A.
Yeah, like this.
Sorry about the type of A. works we have to command interplay the univariate splicing data zero and
data one and restore this function and name it spline smooth.
So now we can run this and we can plot it.
So once again, let me copy this here without the first line.
So now we plot the data.
So actually, I would say we don't have to plot the initial data this time.
We can just do it like this.
Just plot the scatter data and then the updated function here, which is called splice moved.
And if you compare this to the other plots, maybe it looks already a bit more smooth.
For example, here you have this large peak, which is totally unreasonable.
And here it is, almost gone, so it looks much better already.
And to improve this, we can tune the smoothness factor so we can write splain smoothed dot set on a
school smoothing on the score factor.
Now we must specify some number, for example.
50.
See, it's even smoother if we go 500.
And you see, it's very, very smooth.
And this is exactly what we wanted.
So you see, by controlling the smoothing factor, we you yeah, we basically disregards that every
point must be fitted perfectly and we must just roughly fit all the points by, such as flying here.
And you see, this is a much better function that describes the physics much better.
But of course, it is not any more.
A piece wise defines blind, so it is a bit of a different thing.
And this is because we have called here to command univariate line, which is something different.
But I want I don't want to go into more details here.
I want to go straight to the next lecture where we will define a model function.
And then we try to optimize the parameters so that this model of function describes what data best because
this is typically the way physicists or I would say other scientists also fit some experimental data
and disciplines are, of course, a very, very nice because they are a nice mathematical tool for fitting
or for interpolating the data.
But often they don't reproduce the correct mechanism that is behind the data.
So I hope you stay tuned and let's go together into the next lecture.