[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: |
Henry F. Mollet |
Subject: |
Re: Was Location of probability PDF's and CDF's in gnuplot?.Now fitting curves to data in gnuplot? |
Date: |
Tue, 30 Aug 2005 19:59:26 -0700 |
User-agent: |
Microsoft-Entourage/11.1.0.040913 |
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?
on 8/29/05 7:56 PM, Paul Kienzle at address@hidden wrote:
> Henry,
>
> leasqr is Levenberg-Marquardt NLLS.
>
> - Paul
>
> On Aug 29, 2005, at 10:11 PM, Henry F. Mollet wrote:
>
>> Thanks Paul and Dimitri for pointing out that all these PDF's and
>> CDF's are
>> located in stat.inc in /sw/share/doc/gnuplot/demo.
>>
>> The reason I'm using gnuplot rather than Octave is because I want to
>> take
>> advantage of fit in gnuplot. I believe the equivalent is not available
>> in
>> Octave. Fit in gnuplot allows the use of any user-defined function and
>> it
>> then uses a non-linear least-squares (NLLS) Marquarde-Levenbert
>> algorithm.
>> It produces parameter values with asymptotic standard errors (A.S.E)
>> for all
>> the parameters.
>>
>> I saw that octave-forge has expfit.m, leasqr.m, wpolyfit.m and the
>> corresponding demos but this does not appear to be as general as fit in
>> gnuplot?
>>
>> My question here is how can I get the results from gnuplot (e.g. the
>> fitting
>> parameters into Octave for further processing. I am in Octave already
>> rather
>> than gnuplot and am using graw commands to do the fitting. I want to
>> calculate the loss function, aka WSSR, aka SSR, in parameter space. I
>> would
>> know how to do this in Octave and then plot the results but have no
>> clue how
>> to calculate what I need in gnuplot.
>> Henry
>>
>> on 8/26/05 9:44 PM, Paul Kienzle at address@hidden
>> wrote:
>>
>>>
>>> Avocado:~ paulkienzle$ locate prob.dem
>>> /sw/share/doc/gnuplot/demo/prob.dem
>>> /Users/paulkienzle/darwinports/dports/math/gnuplot/work/gnuplot
>>> -3.8h.0/
>>> demo/prob.dem
>>>
>>>
>>> The functions are defined in stat.inc in the same directory. For
>>> logistic it is:
>>>
>>> # Logistic PDF
>>> logistic(x)=lambda*exp(-lambda*(x-a))/(1.0+exp(-lambda*(x-a)))**2
>>>
>>> Note that many statistical functions are defined in Octave, though in
>>> the case of logistic_pdf, it does not include the lambda and a
>>> parameters so you instead need to use:
>>>
>>> y = lambda*logistic_pdf(lambda*(x-a))
>>>
>>> to get the same function as gnuplot.
>>>
>>> - Paul
>>>
>>>
>>> On Aug 26, 2005, at 11:15 PM, Henry F. Mollet wrote:
>>>
>>>> Where are the probability PDF's and CDF's located in gnuplot so I can
>>>> set
>>>> the path that they can be found. When in my home directory and trying
>>>> for
>>>> example 'logistic(x)' the function cannot be found. After I load the
>>>> demo
>>>> 'prob.dem' and do a few functions and then quit, plot logistic(x)
>>>> will
>>>> work
>>>> using my own parameters for a and lambda.
>>>> Henry
>>>>
>>>> gnuplot> show loadpath
>>>> loadpath is "/usr/local/share/gnuplot/demo/"
>>>> "/usr/local/bin/gnuplot"
>>>> system loadpath is
>>>> gnuplot> pwd
>>>> /Users/hfm
>>>> gnuplot> plot logistic(x)
>>>> undefined function: logistic
>>>>
>>>> gnuplot> load 'prob.dem'
>>>> Statistical Library Demo, version 2.3
>>>> Copyright (c) 1991, 1992, Jos van de Woude, address@hidden
>>>> NOTE: contains 54 plots and consequently takes a lot of time to run
>>>> Press Ctrl-C to exit right now
>>>> Press Return to start demo ...
>>>> Hit return to continue^C
>>>> gnuplot> plot logistic(x) # Now I get a graph
>>>> gnuplot>
>>>>
>>>> I assume that default value would be used for the parameters if I
>>>> don't give
>>>> them but this is not the problem:
>>>> gnuplot> plot logistic (x)
>>>> undefined function: logistic
>>>> gnuplot> a = 0.0
>>>> gnuplot> lambda = 2.0
>>>> gnuplot> mu = a
>>>> gnuplot> sigma = pi/(sqrt(3.0) + lambda)
>>>> gnuplot> plot logistic (x)
>>>> undefined function: logistic
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -------------------------------------------------------------
>>>> 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
>>>> -------------------------------------------------------------
>>>>
>>>
>>>
>>>
>>> -------------------------------------------------------------
>>> 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
>>> -------------------------------------------------------------
>>>
>>
>>
>
-------------------------------------------------------------
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
-------------------------------------------------------------