On Feb 27, 8:48 pm, Carl Witty <[email protected]> wrote:
> On Feb 27, 9:47 am, linuxgus <[email protected]> wrote:
>
> > Can somebody shed some light on this and/or suggest alternative ways
> > of doing this?
>
> Well, when I try debugging this (that is, run your code, see it crash,
> type: %debug to get into the debugger where I can run code), I see
> that your function is returning a 150x1 array and it's being called in
> a context that's expecting a scalar.
>
> Carl
Thank you for your response. I don't know how to use '%debug'. Is it
callable from the notebook? However, after studying your response and
my code very carefully (and also the help for 'find_fit'), I realized
that the variables declared to 'find_fit' should NOT be the whole data
array but a variable scanning its columns. So, I changed the code to
this:
def elp(u,v,X,Y,x1,y1,x2,y2,l1,l2) :
return l1 * ( (x1 * (u - X))**2.0 + (y1 * (v - Y))**2.0 ) +
l2 * ( (x2 * (u - X))**2.0 + (y2 * (v - Y))**2.0 )
S=find_fit(B,elp,parameters=[X,Y,x1,y1,x2,y2,l1,l2],variables=
[u,v],solution_dict=1)
Now, I don't get any errors, but I get the following warning:
Warning: Number of calls to function has reached maxfev = 1800.
I don't know what 'maxfev' is and how it can be changed. The results
I get are garbage:
S
{y2: -3.101056277597387e-05, x2: -0.014795273272515948, y1:
-0.016585386583051458, l2: 2.4208803807921435, l1: 1.8611946964366821,
Y: 38.827419094787871, X: 21.409518945966315, x1:
-0.00091457979205344789}
Of course, there may well be something wrong with my math. However, I
would like to know what that cryptic warning means. I get different
(garbage) results for every run, probably because the randomization
changes the data points a bit from run to run.
Gus
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---