Somewhere along the path the second argument to scipy.special.lambertw
(0) is being converted to a float:

>>> import scipy.special
>>> scipy.special.lambertw
<built-in function lambertw>
>>> scipy.special.lambertw(1, 0)
(0.56714329040978384+0j)
>>> scipy.special.lambertw(float(1), 0)
(0.56714329040978384+0j)
>>> scipy.special.lambertw(float(1), float(0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "lambertw.pyx", line 340, in scipy.special.lambertw.lambertw
(scipy/special/lambertw.c:1378)
TypeError: ufunc '' not supported for the input types, and the inputs
could not be safely coerced to any supported types according to the
casting rule 'safe'

If you (1) bypass this by using a Python function and making a number
explicitly, (2) use something like the abs of LambertW, and (3) change
your introduced error to be smaller  -- multiplying by
normalvariate(0, 1) is pretty hard to recover from! -- then it should
work:

##############
def g(t,a,b,c):
    return abs(a*lambert_w(b*t-c).n())

a = 1.2
b = 0.5
c = 0.1

data = [(i, g(i, a, b, c) + normalvariate(0, 0.05)) for i in
xsrange(0, 4*pi, 0.2)]
var('a, b, c, x')
model = g
fit = find_fit(data, model, parameters=[a,b,c], variables=[x])
##############

produces

sage: fit
[a == 1.166896678207367, b == 0.5327270673942398, c == 0.1220748294541312]

which isn't bad.


Doug

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to