1
00:00:00,120 --> 00:00:06,890
So far, we have discovered the Taylor expansion, we have discussed the properties of polynomials,

2
00:00:06,900 --> 00:00:13,770
and we have found that basically any continuous function can be expanded in terms of a Taylor expansion.

3
00:00:14,490 --> 00:00:20,040
So of course, in this total expansion, we can never take into account all terms because there is an

4
00:00:20,040 --> 00:00:23,880
infinite number of these terms, but we have to stop at some point.

5
00:00:24,750 --> 00:00:31,470
But we've also seen that even for difficult functions, the approximate form of the Taylor expansion

6
00:00:31,470 --> 00:00:38,670
works quite well in the vicinity of the value zero that we have chosen for the expansion of the series.

7
00:00:39,660 --> 00:00:47,190
So what we do next is we will use polynomials to interpolate functions or better to say, to interpolate

8
00:00:47,190 --> 00:00:51,060
data, to get the function that describes this data.

9
00:00:51,690 --> 00:00:57,300
So this is a very, very common phenomenon in science and in physics, for example, where you do some

10
00:00:57,300 --> 00:01:04,530
measurement and you know, the mechanism that is behind the data that gave rise to the data.

11
00:01:04,980 --> 00:01:10,770
And then you have a model function, for example, and then you try to fit some parameters so that you

12
00:01:10,770 --> 00:01:18,600
find out what exactly are the parameters that allow you to describe the measured data in terms of the

13
00:01:18,600 --> 00:01:19,500
model function?

14
00:01:20,250 --> 00:01:27,840
And of course, I could have just started this lecture here by giving you some data points, but I think

15
00:01:27,840 --> 00:01:34,380
it's also a good practice and a good exercise to to find these data points and to generate the data.

16
00:01:34,860 --> 00:01:40,680
And also then I can be very honest with you what the data is and how it has been generated.

17
00:01:41,850 --> 00:01:48,480
So first of all, I will define here a function called correct data.

18
00:01:49,320 --> 00:01:51,210
Sorry, correct function.

19
00:01:53,180 --> 00:01:59,570
And the argument would just be so this will be a one dimensional problem and the future will be some

20
00:01:59,570 --> 00:02:02,900
polynomial because we have seen that polynomials are quite nice.

21
00:02:03,350 --> 00:02:07,940
So let's use a polynomial here, but it's in general not really necessary to do.

22
00:02:08,509 --> 00:02:14,630
But I will use it because then we know also the coefficients.

23
00:02:15,140 --> 00:02:17,810
So I will talk about this in a second.

24
00:02:18,350 --> 00:02:19,760
So this will be our function.

25
00:02:22,310 --> 00:02:28,400
And you see, it's a third order polynomial where we have four coefficients 15 two point four minus

26
00:02:28,400 --> 00:02:32,690
0.5 and minus zero point three five.

27
00:02:33,680 --> 00:02:40,390
And what we will do later on this, we will establish a model function, which will be a polynomial

28
00:02:40,400 --> 00:02:41,990
and a third order polynomial.

29
00:02:42,380 --> 00:02:50,240
And then we will try to fit the coefficients here to fit the data that we are going to create using

30
00:02:50,240 --> 00:02:51,290
this correct function.

31
00:02:51,290 --> 00:02:56,810
And then we can compare if the parameters that we have determined by this fit are correct because we

32
00:02:56,810 --> 00:02:58,280
know what are the correct values.

33
00:02:58,280 --> 00:02:59,690
These are these coefficients you.

34
00:03:01,230 --> 00:03:09,570
So let me go ahead and define some some constants here, called number of points.

35
00:03:10,200 --> 00:03:16,650
And let's use 21 and then we have an ex list that is given violin space.

36
00:03:18,820 --> 00:03:24,730
And it goes from minus five to five, and the number of points will be and points.

37
00:03:26,020 --> 00:03:34,330
And our data with which we will start will be data zero will be an array and the coordinates will of

38
00:03:34,330 --> 00:03:43,330
course be given by the list at the Y, coordinates will be given by a correct function acting on the

39
00:03:43,330 --> 00:03:44,020
ex list.

40
00:03:45,460 --> 00:03:54,310
So I run both of these cells and now we should have our data so we can we can look at it by writing.

41
00:03:57,070 --> 00:03:59,200
But clotting experts is why.

42
00:04:00,040 --> 00:04:01,990
So we can do it like this, of course.

43
00:04:02,470 --> 00:04:10,720
And then we just write penalty dot plot data, zero comma data one.

44
00:04:11,620 --> 00:04:15,610
And of course, we want to plot here data zero and data zero.

45
00:04:16,750 --> 00:04:19,329
So this will be our third order polynomial.

46
00:04:19,720 --> 00:04:21,640
And if I use your scatter.

47
00:04:24,250 --> 00:04:30,070
With Tuti, of course, then you see, this is our data that we have generated, and these are the points

48
00:04:30,070 --> 00:04:31,480
that we try to fit.

49
00:04:33,040 --> 00:04:39,670
However, in reality, when you do measurement and experiment, the measured data is not always that

50
00:04:39,670 --> 00:04:40,360
perfect.

51
00:04:40,390 --> 00:04:44,230
So there is some noise in the data and there is some error in the data.

52
00:04:44,830 --> 00:04:48,190
And here, for example, you could definitely see easily, OK?

53
00:04:48,220 --> 00:04:51,310
We just take a 3.0 polynomial and then it should work.

54
00:04:51,310 --> 00:04:56,650
But actually, this data will be blurred and it will be distorted in reality.

55
00:04:57,520 --> 00:05:03,520
So what we will do next is we will modify the X and Y values by adding some random numbers, and I will

56
00:05:03,520 --> 00:05:08,860
do this in the following way we will right and p dot random dot rant.

57
00:05:10,630 --> 00:05:12,910
And then we can just say, for example, end points.

58
00:05:13,900 --> 00:05:21,220
And this will give us an array of 21 points in this or 21 random values in this case, and the random

59
00:05:21,220 --> 00:05:23,800
values will be in the range of zero and one.

60
00:05:24,790 --> 00:05:32,680
So if we want to have it in the range of minus one and one, we just have to subtract one and then we

61
00:05:32,680 --> 00:05:33,880
have to multiply

62
00:05:36,670 --> 00:05:37,140
two.

63
00:05:37,150 --> 00:05:40,270
But only two the first yeah, to to randomize itself.

64
00:05:41,080 --> 00:05:44,890
So then the range will be from minus one to plus one.

65
00:05:46,150 --> 00:05:51,100
OK, and then we can, of course, scale it with any value that we want, for example, zero point one

66
00:05:51,100 --> 00:05:57,340
and then the range will be in the range of minus 0.1 + + 0.1.

67
00:05:58,510 --> 00:06:05,770
So what I will do next is I will create P file or an R equal data and it will be an array.

68
00:06:08,440 --> 00:06:18,340
And this array will be based on our previous data as a data zero and data one, data zero zero and data

69
00:06:18,340 --> 00:06:18,940
zero one.

70
00:06:19,360 --> 00:06:25,270
And so I can basically it could just copy them here.

71
00:06:25,270 --> 00:06:35,230
But what I want to do instead is I will write X List, which is data zero zero plus, and then I tested

72
00:06:35,230 --> 00:06:36,040
what looks good.

73
00:06:38,290 --> 00:06:46,000
Basically, this random random command here, this array of random numbers scaled by a 0.25.

74
00:06:46,480 --> 00:06:47,980
So this will be the will you.

75
00:06:48,550 --> 00:06:50,920
And then for the Y value, we take

76
00:06:53,860 --> 00:06:56,390
our basically or.

77
00:06:57,790 --> 00:07:01,420
So so we have we could also see just data zero zero.

78
00:07:02,020 --> 00:07:04,570
And then for the Y value, we take data zero one.

79
00:07:05,740 --> 00:07:08,650
And here we add a similar thing.

80
00:07:09,550 --> 00:07:15,580
But I tested that's 0.25 is maybe a bit too low.

81
00:07:15,850 --> 00:07:18,910
Let's use a higher value of five point zero.

82
00:07:19,990 --> 00:07:23,010
So I think, or I hope that I don't have a typo here.

83
00:07:23,020 --> 00:07:30,320
Let's test let's copy this code and use data instead of data zero.

84
00:07:32,290 --> 00:07:36,490
And OK, yeah, we have some blurred values here.

85
00:07:38,160 --> 00:07:41,400
So what we can do now also is we can

86
00:07:44,220 --> 00:07:50,790
plot the actual function to see what is here, the difference so we can write X list.

87
00:07:51,300 --> 00:07:55,530
Well, we could also write, you know, later zero

88
00:07:57,900 --> 00:08:05,910
zero and date zero one and the color will be black.

89
00:08:08,040 --> 00:08:12,960
So this will be the correct function that we have used for creating the data.

90
00:08:13,320 --> 00:08:20,880
And then you see, due to the random fluctuations we have that our data on this one will be a bit different.

91
00:08:21,300 --> 00:08:29,490
So this could be quite real realistic physical situation from a measurement where you have some noise

92
00:08:29,730 --> 00:08:30,810
on top of your data.

93
00:08:32,130 --> 00:08:38,100
And so in the following, we will discuss which options we have to fit this function.

94
00:08:38,370 --> 00:08:43,799
For example, I mean, we know what is the correct function to fit this because we have created the

95
00:08:43,799 --> 00:08:44,250
data.

96
00:08:44,790 --> 00:08:47,370
But let's say we have just a measurement with these points.

97
00:08:47,760 --> 00:08:53,520
How would we find out what would be a good fit or a good description of this data?

98
00:08:54,180 --> 00:08:59,580
And then the following lectures we will talk about spleens and fitting model functions.

