From observations to a fitted model

A data-fitting model maps observed inputs to modeled outputs by choosing coefficients for a specified set of functions. The design matrix records what each observation contributes to those outputs; the measured values stay in a separate response vector. This separation lets us ask whether one set of coefficients explains every measurement exactly or only approximately.

Build the fitting system

For the linear model y≈c0+c1xy\approx c_0+c_1x, the basis functions are 11 and xx. An observation (xi,yi)(x_i,y_i) contributes the row (1,xi)(1,x_i) to AA and the value yiy_i to bb. If the model is quadratic, use (1,xi,xi2)(1,x_i,x_i^2) instead; each column follows the corresponding coefficient's basis function.


Multiplication AcAc produces a prediction for each recorded input. The observed-minus-predicted difference ri=yi−(Ac)ir_i=y_i-(Ac)_i is a residual. Keeping the row and response in the same observation order is essential: otherwise a mathematically valid multiplication compares a prediction with the wrong measurement.

Worked example

Consider observations (−2,0)(-2,0), (0,1)(0,1), and (3,4)(3,4) under a linear model. The rows of AA are (1,−2)(1,-2), (1,0)(1,0), and (1,3)(1,3), while b=(0,1,4)Tb=(0,1,4)^T. The first two points give intercept 11 and slope 1/21/2, so their line predicts 5/25/2 at x=3x=3, not the observed 44.


Consequently, interpolation, which requires every residual to be zero, is impossible with one line for these three observations. A least-squares fit instead chooses coefficients that minimize ∑iri2\sum_i r_i^2 over all three points. Its purpose is to balance the discrepancies according to that stated objective, without discarding the last measurement or pretending that every prediction equals its observation.



Fit y≈a+bx to observations (1,4), (2,5), and (4,8), in that order. Which A and response vector z are correct for Ac≈z with c=(a,b)T?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

For observations (0,1), (1,3), and (2,4), a line y=a+bx is proposed. Which statement is correct?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A proposed line is ŷ=1+2x. At x=0,1,2 the measured y-values are 1,3,6. Define residual as observed minus predicted. Which residual vector and squared-error sum are correct?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors