help-octave
[Top][All Lists]
Advanced

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

Re: Was Location of probability PDF's and CDF's in gnuplot?.Now fitting


From: Paul Kienzle
Subject: Re: Was Location of probability PDF's and CDF's in gnuplot?.Now fitting curves to data in gnuplot?
Date: Wed, 31 Aug 2005 05:21:15 -0400

Henry,

leasqrdemo.m contains one function (leasqrdemo) and two private functions (leasqrfunc and leasqrdfdp).

Private functions are available in the symbol table of the main function even though they appear later in the file. For compatibility, you do not need an endfunction between the main and private functions. This isn't true when you are entering commands from the main function at the prompt.

The Levenberg-Marquardt algorithm (http://en.wikipedia.org/wiki/Levenberg-Marquardt_algorithm) uses dfdp to calculate the direction of the gradient. If dfdp is not available it can be approximated by numerical differentiation.

- Paul

On Aug 30, 2005, at 10:59 PM, Henry F. Mollet wrote:

Many thanks. It worked and testdata gave same results as in gnuplot.
I have a few additional questions.
Henry
%function [f,p,kvg,iter,corp,covp,covr,stdresid,Z,r2]=
%                   leasqr(x,y,pin,F,{stol,niter,wt,dp,dFdp,options})

As per above minimum input required is
[f,p, ......]=leasqr(testdata(:,1),testdata(:,2),pin,F)

Need pin which are initial (start) parameters,
required as no default values are chosen.

Need F (=fitting/model function).  In demo it is:
F = @leasqrfunc;
% error: error creating function handle "@leasqrfunc"
% Needs to go after function unless it is used in a function
function y = leasqrfunc(x,p)
  y=p(1)*exp(-p(2)*x);
endfunction % apparently not needed in demo
F = @leasqrfunc; % needs to be after function

1. In leasqrdemo.m  function handle appears before the function
And it works. I had to put it after when checking line by line?

2. Why does the above function y = leasqrfunc(x,p) not require an
'endfunction' in leasqrdemo.m?

3. I do not understand the optional input parameter dFdp
I can see that the partial derivatives are calculated but what is it for?
dFdp = @leasqrdfdp; % exact derivative
function y = leasqrdfdp(x,f,p,dp,func)
y= [exp(-p(2)*x), -p(1)*x.*exp(-p(2)*x)];
% again no 'endfunction' required in leasrdemo.m?



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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