help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fit data - trendline through zero


From: Eric Ortega
Subject: Re: fit data - trendline through zero
Date: Wed, 16 Dec 1998 01:07:54 -0500 (EST)


On Wed, 16 Dec 1998, Joao Cardoso wrote:

> Eric Ortega wrote:

<snip>

> > 
> > At this point, the `m' in `y=mx':
> > 
> >   m = sum(x_h'*y_h)/sum(x_h'*x_h);
> > 
> why not use: 
> 
>   b = pinv(x)*y
> 
> where x and y are column vectors? try "help ols"
> 


This would seem reasonable as well, notice that the solution I gave is
only dependent on `sum', I wasn't aware of the pinv function.

In Matlab this function is supported with the \ operator, i.e: 

  A*x = b <==> x = A\b

Matlab does a pseudoinverse at this point, and generally comes up with a
better solution than the method I gave.  I'm not too familiar with octave
yet, did a quick search for a `\' type operator, couldn't find one, and
defaulted to a function based solely on `sum', which I know exists.


                                        adios,
                                          eo



p.s.  By "better solution" I mean a little bit better, due to better
handling of number storage issues (rounding and truncating), in no 
way is doing what I suggested "wrong".  :)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]