This project has moved and is read-only. For the latest updates, please go here.

Does MathNet.Numerics support extrapolation?

Feb 8, 2013 at 9:33 PM
I've got the CubicSplineInterpolation working just fine doing interpolation. Now I'm trying to get extrapolation working but I don't see this supported in any of the relation functions. Am I missing something or is there another package which handles this?

Thanks in advance.
Feb 8, 2013 at 10:47 PM
Technically all the interpolation algorithms support extrapolation to values outside of the sample set range. Just be aware that it follows along exactly the same interpolated high-order function, so there is a high risk of producing garbage. Depending on your scenario, some form of regression may help to reduce the order in such cases.

Thanks,
Christoph
Marked as answer by cdrnet on 10/3/2013 at 5:49 PM
Feb 8, 2013 at 11:41 PM
Edited Feb 9, 2013 at 12:57 AM
Thanks for the reply. That's great news, this is a nice package.

Last question: Is it required that the 2 input vectors (eg. samplePoints and sampleValues inputs to the CubicSplineInterpolation() function) be monotonic? Or does this depend on which spline implementation I choose? I thought I remembered from college that splines require the two input vectors to be monotonically increasing or decreasing but I wasn't sure if that's specific to which splining method is used or if this was a general rule for all splines. Ideally I would like to choose an implementation that works with non-monotonic inputs too.

Thanks for the response,

Alex
Feb 9, 2013 at 12:31 AM
Edited Feb 9, 2013 at 12:32 AM
To my understanding, all our interpolation algorithms expect the samples to be sorted ascendingly by the sample point, although I'd have to check the specific algorithm if needed. The sample points thus do have to be strictly monotonically increasing, but there is no restriction on the sample values.

I fact, even if the sample values were monotonic, the resulting function could still be non-monotonic. Note that there is an adaption if there is a requirement that the resulting function be monotonic, i.e. a monotonic spline. A simple way to achieve this, provided the sample values are in fact monotonic, is to modify the spline derivatives (e.g. computed using CubicSplineInterpolation.EvaluateSplineDerivatives) to all have the same sign and feed them directly into a cubic hermite spline instead.

Thanks,
Christoph