title: TypeError: 'numpy.int64' object is not callable — What does that mean in laymans terms?
body: <p>I'm trying to perform a non-linear regression after <a href="http://lister.dulci.duhs.duke.edu/~cliburn/summer-school/python/_build/html/model_fitting.html" rel="nofollow">this example</a> with my own sigmoidal model:</p>
  
  <p>$$f(d) = \frac{1}{1 + \exp (-k (d-e))}$$</p>
  
  <p>The example explained on the website works perfectly, but not so my code: </p>
  
  <pre><code>import pylab
  import numpy
  from scipy import optimize
  
  def f(d, k, e):
      return 1 / (1 + numpy.exp(-k(d-e)))
  
  def resid(p, y, d):
      k, e = p
      return y - f(d, k, e)
  
  
  # load the data
  d, r, n = numpy.loadtxt('data.txt', unpack=True)
  
  y = numpy.concatenate([d, r])
  
  k0, e0 = 1, 10
  
  [k, e], flag  = optimize.leastsq(resid, [k0, e0], args=(d, r))
  
  print flag, k, e
  
  # plot the data
  pylab.plot(d, r, 'ro')
  
  pylab.show()
  </code></pre>
  
  <p>However, when I execute the script, it throws the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "./logisticfit.py", line 22, in &lt;module&gt;
      [k, e], flag  = optimize.leastsq(resid, [k0, e0], args=(d, r))
    File "/Library/Python/2.7/site-packages/scipy-0.12.0.dev_d631749_20121222-py2.7-macosx-10.8-intel.egg/scipy/optimize/minpack.py", line 348, in leastsq
      m = _check_func('leastsq', 'func', func, x0, args, n)[0]
    File "/Library/Python/2.7/site-packages/scipy-0.12.0.dev_d631749_20121222-py2.7-macosx-10.8-intel.egg/scipy/optimize/minpack.py", line 14, in _check_func
      res = atleast_1d(thefunc(*((x0[:numinputs],) + args)))
    File "./logisticfit.py", line 12, in resid
      return y - f(d, k, e)
    File "./logisticfit.py", line 8, in f
      return 1 / (1 + numpy.exp(-k(d-e)))
  TypeError: 'numpy.int64' object is not callable
  </code></pre>
  
  <p>There clearly is a TypeError somewhere, but I don't understand where or what exactly the problem is. I have tried searching Google for this error, but also I don't quite understand the explanations. Ideas, anyone?</p>
  
  <hr>
  
  <p>data.txt</p>
  
  <pre><code>0.0 0.0 6
  4.5 0.0 3
  6.1 0.333333333333  3
  7.7 0.0 3
  8.5 0.2 10
  9.0 0.6 5
  9.3 0.333333333333  3
  9.5 0.333333333333  6
  10.0    0.333333333333  6
  10.5    0.8 5
  10.9    0.5 2
  11.0    1.0 5
  11.5    1.0 5
  12.0    1.0 4
  12.5    1.0 8
  13.0    1.0 1
  </code></pre>