Professional Documents
Culture Documents
Use the method of least squares, find the constant function that best fits the data
x -1 2 3
y 5/4 4/3 5/12
(a) What straight line best fits the following data in the least-squares sense?
x 1 2 3 4
y 0 1 1 2
(b) Find the equation of a parabola of form y = ax2 + b that best represent the data in
least squares
x -1 0 1
y 3.1 0.9 2.9
(a) We are given a data set (xk , yk ), k = 0 . . . m. For these data we shall fit in the
function
g(x) = α sin x + β cos x.
Set up the normal equations that will solve the problem with the method of least squares.
Now, given the data set
as small as possible?
1
where
B = world population
T = the time
KF = the fertility constant.
The solution of the equation is givenby
1 1
B(T ) = ·
KF T0 − T
Throughout the years we have got the following observation data:
T 1650 1700 1750 1800 1850 1900 1920 1940 1960
10−6 · B 545 623 728 906 1171 1608 1834 2295 3003
where T is the year and 10−6 · B equals to numbers of millions of people.
a). Let y = 1012 /B, and x = T − 1830, and rewrite the equation into the form
y(x) = a0 + a1 x.
b). Use the method of least squares to decide a0 and a1 .
c). Then, find KF and T0 . Now you can write out the function B(T ) that describes
the population B as a function of time T .
d). What is your T0 ? What does it tell you?
e). Use the model to predict the population for T = 1980, T = 2000 and T = 2010.
Are you happy with the result? Comparing to the actual population in 2011,
which is about 7.1 billions, what would you say about this model?
2
6. The method of least squares in Matlab
Use Matlab function polyfit to find respectively the first, second, fourth and eighth
order polynomials that best fit the data, in the method of least squares. You would
rather plot your polynomials.
What to hand in: The script file, the plots, and your comments.