title: Minimizing a function of a linear combination of data with Scipy
body: <p>Suppose I have some matrix X where each row represents a time-series. For example, X could be a matrix of size 3 x 1000, which would mean that there are 3 time-series each consisting of 1000 time-points. In addition to X, I have one scalar for each time-series in X. I would like to find a linear combination</p>
  
  <p>a[0] * X[0, :] + a[1] * X[1, :] + ... + a[n-1] * X[n-1, :]</p>
  
  <p>that has the minimum value for some function F.</p>
  
  <p>So, I attempted the following</p>
  
  <pre><code>import numpy as np
  from scipy.optimization import minimize
  def f(x):
      return 0 # for testing purposes
  def obj(a,x):
      y = a*x
      return f(y)
  minimize(obj, np.array([1,1]), args=np.array([[1,1],[2,2]]), method='nelder-mead')
  </code></pre>
  
  <p>So the second argument is the initial guess x0 (the coefficients a). The data given by args should get mapped to x (if I understand it correctly) and remains constant during the optimization.</p>
  
  <p>However, I get the error </p>
  
  <pre><code>ValueError: setting an array element with a sequence.
  </code></pre>
  
  <p>I guess my problem is pretty general one, so I hope someone would be able to help!</p>