[SciPy-user] SciPy cubic interpolation coefficients

josef.pktd@gmai... josef.pktd@gmai...
Sun Jun 21 16:52:27 CDT 2009


On Sun, Jun 21, 2009 at 5:28 PM, <josef.pktd@gmail.com> wrote:
> On Sun, Jun 21, 2009 at 4:13 PM, Celvin<read.beyond.data@gmx.net> wrote:
>> josef.pktd@gmail.com @ Jun, 21, 2009 09:23PM
>>
>>> Did you try
>>> UnivariateSpline.get_coeffs()
>>
>>> UnivariateSpline.get_knots()
>>
>> >From my experiments with interpolate splines, I would think this
>>> provides what you want. But the documentation is still a bit sparse.
>> Yes, I did try using UnivariateSpline. Apart from being "more off"
>> than using splrep with a smoothing factor of 0, get_coeffs() also
>> returns an 1-d array, with far too few coefficients.
>>
>> Assuming a signal with about 390 data points, I also expect about
>> 390 coefficients (which is consistent with what I get using
>> signal.cspline1d for example, but I need 4 arrays, not just one).
>>
>> I would expect coefficients to be a list of shape
>>
>> coeff = [ [a0, b0, c0, d0],
>>          [a1, b1, c1, d1],
>>          [a2, b1, c2, d2],
>>          ...
>>          ...
>>          [an, bn, cn, dn],
>>        ]
>>
>> but I am only able to obtain 1-d array of coefficients, no matter what
>> function or module I use.
>>
>> http://www.physics.utah.edu/~detar/phys6720/handouts/cubic_spline/cubic_spline/node1.html
>>
>> ...is basically what I'm looking for. I used to do the matrix
>> calculations for Si(x) myself using C++, but I'd prefer to somehow get the
>> coefficients using numpy/scipy and not use an extension.
>>
>> Any further ideas?
>
> interpolate.spalde   gives you the derivatives of as a 1 by 4 array
> for each point
> given it's a cubic function, it should be possible to recover the coefficients
>
> something like
>
> coeff = np.vstack(interpolate.spalde(x,tck))*[1,1,0.5,1/3.]


I don't think that makes any sense. (sleep deprivation)

Josef

>
> I have no idea yet, whether this actually does what you want.
> If you find out how it works, it would be good to get an example since
> figuring out the splines with the current documentation is pretty
> difficult.


More information about the SciPy-user mailing list