help-octave
[Top][All Lists]
Advanced

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

Re: leasqr and anonymous functions


From: Nose Nada
Subject: Re: leasqr and anonymous functions
Date: Wed, 30 Apr 2008 20:40:21 -0700 (PDT)

Thanks Olaf!
I changed the definition of the anonymous function from @(SD,p) to @(p,SD)
and then leasqr run smoothly. However, all the output was in imaginary
numbers and they must be real. I tried to find if among the input arguments
of leasqr there was the possibility to define lower and upper bounds for the
parameters values, as it is the case in Matlab, but I found nothing. Do you
know if in Octave there is some minimizer of sum of squared residuals that
allows the definition of parameter ranges? Must I use some general minimizer
(e.g. fminbnd  or samin) with that possibility and then define the sum of
residual squares by myself?
I look forward for some help.
Thanks in advance,
Omar





On Tue, Apr 29, 2008 at 07:58:48PM -0700, Nose Nada wrote:
> 
> Hello there!
> 
> I have defined an anonymous function Error with three parameters (SD(1:3))
> and an independent variable p:
> 
> octave:1> SDc = 0.0001; R=1000;
> octave:2> Error = @(SD,p)(SDc^2 + ((1/(R-1) + p).^2)*(SD(1)^2) +
> (((p./((2*(SD(3)^1.5) + 0.6))).*log(1+(10^SD(3)).*(1-p))).^2).*(SD(2)^2));
> 
> It worked fine on evaluation:
> 
> octave:3> Error([0.01 0.01 1], 0:0.1:1) 
> ans =
> 
>    1.0100e-08   1.8144e-06   6.9068e-06   1.4827e-05   2.5052e-05  
> 3.6983e-05   4.9925e-05   6.3081e-05   7.5597e-05   8.6947e-05  
> 1.0021e-04
> 
> However, when I tried to fit it to experimental data using 'leasqr', it
> fails:
> 
> octave:4> leasqr((0:0.1:1)',(0.001:0.001:0.011)', [0.01 0.01 1], Error)
> error: operator -: nonconformant arguments (op1 is 11x1, op2 is 3x1)
> error: evaluating binary operator `-' near line 182, column 9
> error: evaluating binary operator `.*' near line 182, column 5
> error: evaluating assignment expression near line 182, column 2
> error: called from `leasqr' in file
> `/usr/share/octave/packages/optim-1.0.0/leasqr.m'
> 
> 
Have not looked thoroughly through your function Error, but it seems
to have its arguments in the wrong order. Although the second argument
is named 'p', the function seems to treat it as the data, not the
parameters. leasqr calles Error with p = [0.01 0.01 1], so error
returns only 3 values instead of 11.

Olaf
_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave



-- 
View this message in context: 
http://www.nabble.com/leasqr-and-anonymous-functions-tp16974766p16992810.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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