title: Using a guess with scipy curve_fit
body: <p>I have a function that I want to curve fit with knowing the error of the curve fit. I'm trying to use scipy.optimize.curve_fit to do this but am running into problem. Right now my code is:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from scipy.optimize import curve_fit
  
  pi = np.pi
  sqrt = np.sqrt
  mean = np.mean
  
  A = 1
  T_2 = 100
  nu_0 = 10
  phi_0 = 0
  n = .001
  nu_s = 500
  T = 1000
  
  t = np.linspace(0, T, num = (nu_s*T))
  
  def S_n(A,t,T_2,nu_0,phi_0,n,nu_s,T):
      return (A/np.sqrt(2))*np.exp(-t/T_2)*np.cos(2*pi*nu_0*t+phi_0)
  
  S = S_n(A,t,T_2,nu_0,phi_0,n,nu_s,T) + np.random.normal(0, n, nu_s*T)
  
  guess = np.array([A,T_2,nu_0,phi_0,n,nu_s,T])
  print guess
  
  popt, pcov = curve_fit(S_n,t,S, guess)
  print popt
  perr = sqrt(np.diag(pcov))
  print perr
  </code></pre>
  
  <p>Which gives me infinite error. I'm not sure I am doing my guess correctly because in the equation, everything remains constant except t, so do I leave t out of my guess because it is no longer an array because t is a sequence. When I leave t out of the guess, which I am doing here I receive values for each variable to be far from the values I give initially with infinite error. If I include t in the guess, then I get an error.</p>