Hi there.
I've now tried various functions in the scipy.interpolate package without getting far. What I want to do: I want to interpolate using spline interpolation, cubic spline interpolation to be more precise. 1. I want to be able to choose which points to interpolate (to choose between which points on the x-axis the cubic polynomials are). Then I'll have some polynomials on the form ax^3 + bx^2 + cx + d 2. Then I want to be able to extract the coefficients a,b,c,d from each polynomial because that's the only thing I want to keep. I don't want to keep an interpolation object of some sort. Input: Two lists, one representing the x-axis: [0..n] and another one with the function values: [y0, y1, y2, ... , yn] and the desired points I wish to interpolate between. Output (preferably): The coefficients (a,b,c,d) for every polynomial beetween the points I chose to interpolate between. Any help at all will be greatly appreciated. Cheers. Jón Gísli Egilsson. _______________________________________________ SciPy-user mailing list [hidden email] http://mail.scipy.org/mailman/listinfo/scipy-user |
I'm not sure I fully understand your question, but I think
scipy.interpolate.InterpolatedUnivariateSpline is what you want - fit your spline with that, then if you want to get the properties of the spline at some subset of points, just use those values. Specifically, suppose you have your data as x and y vectors. Do s=scipy.interpolate.InterpolatedUnivariateSpline(x,y) This will subdivide the curve into some number of knots (n-k+1, to be exact), so get the knots with ks = s.get_knots() now, if you want the polynomial, bewteen, say the 1st and 2nd knot, do v = (ks[1]-ks[0])/2 derivs = s.derivatives(v) and derivs will be an array of derivatives at that point, and that gives you the coefficients you want (if I am interpreting your question correctly). On Wed, Jul 8, 2009 at 3:09 AM, Jón Egilsson<[hidden email]> wrote: > Hi there. > > I've now tried various functions in the scipy.interpolate package without > getting far. > > What I want to do: > > I want to interpolate using spline interpolation, cubic spline interpolation > to be more precise. > > 1. I want to be able to choose which points to interpolate (to choose > between which points on the x-axis the cubic polynomials are). Then I'll > have some polynomials on the form ax^3 + bx^2 + cx + d > > 2. Then I want to be able to extract the coefficients a,b,c,d from each > polynomial because that's the only thing I want to keep. I don't want to > keep an interpolation object of some sort. > > Input: > > Two lists, one representing the x-axis: [0..n] and another one with the > function values: [y0, y1, y2, ... , yn] and the desired points I wish to > interpolate between. > > Output (preferably): > > The coefficients (a,b,c,d) for every polynomial beetween the points I chose > to interpolate between. > > Any help at all will be greatly appreciated. Cheers. > > Jón Gísli Egilsson. > > > _______________________________________________ > SciPy-user mailing list > [hidden email] > http://mail.scipy.org/mailman/listinfo/scipy-user > > SciPy-user mailing list [hidden email] http://mail.scipy.org/mailman/listinfo/scipy-user |
Free forum by Nabble | Edit this page |