Javier Ángel Velázquez Muriel wrote: > I've noticed an OpenCubicSpline class in the core module. I couldn't > find an example in the code using grep. Could anybody answer this questions? > > 1) I understand that the values have to be evenly-spaced. Then, why > asking for minrange and spacing ? Why not just use: > minrange = values[0]; > spacing = values[1]-values[0]; > ?
A spline, like any other unary function in IMP, takes some input and returns a score. See http://salilab.org/modeller/manual/node97.html#7695 for what these look like in Modeller - they are pretty similar in IMP.
The range and spacing refer to the inputs - i.e. the x axis. The values[] vector contains output values - i.e. the y axis - between which the spline is created. So the coordinates of the first point on the spline are at (minrange, values[0]), the second at (minrange+spacing, values[1]), and so on.
> 2) What is the minimum number of values required ? 4 ?
Sounds about right. It should complain if you give less, but I'll check the code and docs.
> 3) Do they need to be sorted ?
Huh? I don't understand.
> 4) If I want to compute values out of range, should I use > ClosedCubicSpline ?
No, the closed spline is closed in that the last point on the x axis is equivalent to the first (it wraps around: the second derivatives are equal). So by construction it cannot deal with "out of range" values - it is typically used for something periodic (e.g. an angle). An open spline has zero second derivative at the end points, so will just become a tangent for out of range points.
> 5) Could the author update the help a little bit?
Will do.
> 6) Is the function able to deal with multidimensional interpolation (i.e. if I give it a set of 2D/3D points, can it produce a surface) ? I guess no, but I am curious.
Nope - it is 1D. Higher dimensional splines are possible, but for traditional cubic splines they are either rather expensive in CPU time (lots of matrix inversions) or in memory (storage of lots of intermediate results).
Ben