[Top][All Lists]

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

Re: leasqrdemo

From: Przemek Klosowski
Subject: Re: leasqrdemo
Date: Thu, 28 Sep 2006 22:57:17 -0400 (EDT)

   I am trying to fit function b*(x^a), but I don't know much about fitting
   and I also have problems with derivatives.
   I am using leasqrdemo.m, where I defined

   p = [-1,10];
   function y = leasqrfunc(x,p)
           y = p(2)*(x^p(1))

   but I don't know what the leasqrdfdp should look like.
   function y = leasqrdfdp(x,f,p,dp,func)
           y = [?,?]

You don't need to define the derivatives---if you don't they are
calculated numerically. leasqr() is a wonderful facility, but it like
a race car: temperamental and demanding.  Still, with little care, it
is a pleasure to drive. Here's a simple example:

    x=1:10; y=[12,5,3,2,1,1,1,1,1,1]; p = [-1,10];
    function y = leasqrfunc(x,p)
       y = p(2)*(x.^p(1))


results in a reasonable fit:    pout = [ -1.2841; 12.0054 ]

Note that I changed your function slightly by using the 'scalar'
exponentiation .^ rather than matrix exponentiation, just so that
I can use the function leasqrfunc() on a vector of values, e.g.:


Here's my list of issues with leasqr():

 - it seems to be unnecessarily picky about its input arguments: x,y 
   apparently must be column vectors, as leasqr(x,y,p,"leasqrfunc")
   returns an error.

 - I can't seem to get it to run quietly: it produces output even
   with a semicolon at the end of the command line.

 - the help text is exhaustive but not beginner-friendly; leasqrdemo()
   didn't help me either

I think that leasqr() is an important Octave facility, and I would be
glad to do some work on it. Is there someone else who likes it too, to
discuss what needs done and how? I haven't used leasqr() that much, so
maybe I am missing something.

reply via email to

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