[SciPy-User] scipy.interpolate.KroghInterpolator: output confusion.

Antonio Valentino antonio.valentino@tiscali...
Fri Oct 16 05:40:51 CDT 2009


Il giorno Fri, 16 Oct 2009 05:36:39 -0400
Anne Archibald <peridot.faceted@gmail.com> ha scritto:

> 2009/10/16 Antonio Valentino <antonio.valentino@tiscali.it>:
> > Hi Anne,
> >
> > Il giorno Fri, 16 Oct 2009 03:40:09 -0400
> > Anne Archibald <peridot.faceted@gmail.com> ha scritto:

[CUT]

> >> vector values. To specify derivative information, you must repeat
> >> the x value in question. So to do the interpolation you were
> >> intending, you should do:
> >>
> >> krogh =
> >> interpolate.KroghInterpolator([2,2,3,3,4,4],[10,1,13,2,15,2.5])
> >>
> >> Calling this object then yields scalars. If you want derivatives,
> >> you can ask for as many as you want with krogh.derivatives, which
> >> will provide you with an array, or krogh.derivative, which will
> >> provide you with a particular one.
> >>
> >> This way of specifying derivatives is a little peculiar, but it is
> >> what the underlying algorithm needs, and it also allows you to have
> >> different numbers of derivatives at each point (as with the
> >> example in the docstring).
> >
> > the example seems to conflicts with the rest of the docstring that
> > clearly states:
> >
> > """
> >    Parameters
> >    ----------
> >    xi : array-like, length N
> >        known x-coordinates
> >    yi : array-like, N by R
> >        known y-coordinates, interpreted as vectors of length R,
> >        or scalars if R=1
> > """
> 
> The docstring is a little confusing, I admit, because some yi may be
> derivative values rather than y-values. But they are indeed vectors of
> length R. This allows you to, for example, construct a cubic curve in
> space, so that p(t) = (x,y,z).


Oh, I had completely misunderstood!
Thanks for clarification.

> > xi: N
> > yi: NxR with R = number of derivatives available at each point.
> 
> This is not what the docstring says, and this is not how the code
> works. You do not provide derivative values in this way. Plot the
> polynomial values you get out and you will see.
> 
> > Is it a bug in the documentation?
> 
> Obviously the docstring isn't clear enough, since users are being
> confused by it.

Yes, my suggestion is to add a lot of examples


> > I think that the one described in the docstring is a more handy
> > interface with respect to the one of the example.
> 
> The problem with the interface you are suggesting, in which you
> provide a matrix of function and derivative values, is that it forces
> you to specify the same number of derivatives at each point. The
> current interface allows you to specify more derivatives at some
> points than others. If you want to convert, you can do something like:

again this aspect can be deduced from the example but not clearly
stated in the description

> xs = np.repeat(xi,2)
> ys = np.ravel(np.dstack((yi,ypi)))
> 
> In the docstring itself you see an example of such construction:
> 
> >>> KroghInterpolator([0,0,1],[0,2,0])
> 
> This constructs a quadratic that is zero at zero, zero at one, and has
> a derivative of 2 at one - that is, the quadratic 2*x**2-2*x. There is
> no constraint on the derivative at 1.

thanks 


-- 
Antonio Valentino


More information about the SciPy-User mailing list