title: Cubic spline interpolation get coefficients
body: <p>Say I have two arrays in python and I wish to get (and actually use) the cubic spline interpolation between those points. (IE: I wish to integrate the function). I would strongly prefer a way using numpy scipy.</p>
  
  <p>I know about <a href="https://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.interpolate.interp1d.html" rel="nofollow">scipy.interpolate.interp1d</a>. However that only allows me to evalute the points, for say the very simply function of:</p>
  
  <p>Now I could do something simply like:   </p>
  
  <pre><code>import numpy as np
  import scipy.interpolate
  import matplotlib.pyplot as plt
  
  y = np.array([0,2,3,4,8,10,12,12,12,10,9,8,7,1,0,0,1,2])
  x = np.array(range(len(y)))
  xvals = np.linspace(0, len(y)-1, len(y)*100, endpoint = False)
  func = scipy.interpolate.interp1d(x, y, kind = "cubic")
  yvals = func(xvals)
  plt.plot(xvals,yvals)
  plt.plot(x,y, "o")
  </code></pre>
  
  <p>However I wish to further process this cubic spline (ie I need to get the integration).. For manual doing things I need to get the factors, so:</p>
  
  <pre><code>a_i * x^3 + b_i * x^2 + c_i * x + d_i where i goes from 0 to n/3 
  </code></pre>
  
  <p>(n = number of elemetns - this is just the definition of the ith cubic)</p>
  
  <p>I hence expect a list of tuples (or 2d array) describing all splines. - Or a way to get the ith cubic, and really, really would love to get have a convenience "x-to-i" to find in which spline I am currently. </p>
  
  <p>(Though of course this latter problem is a simple search for first value larger than reference in a sorted list - I could do that by hand easily if need be).</p>