P. 1
Octave Tut

Octave Tut

|Views: 26|Likes:
Published by kozk

More info:

Published by: kozk on Oct 06, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

11/02/2011

pdf

text

original

A common experimental scenario is when you wish to fit a model to a large number of
data points. Each data point can be expressed in terms of the model’s equation, giving a
set of simultaneous equations which are over-determined i.e. the number of independent
equations, m, is larger than the number of variables, n. In these cases it is not possible
to find an exact solution, but the desired solution is the ‘best fit’. This is usually defined
as the model parameters which minimise the squared error to each data point.
For a set of equations which can be written as Ax = b, the least-squares solution is
given by the pseudoinverse (see your IB Linear Algebra notes):

x = AT

A

−1

AT

b

In Octave you can again use the \ operator. For invertible matrices it is defined to
solve the equation using Gaussian elimination, but for over-determined systems it finds
the least squares solution. The pseudoinverse can also be calculated in Octave using the
pinv function, as demonstrated in the following example.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->