I'm attempting to create a SQL function that generates the polynomials required for the interpolating cubic spline. This wouldn't cause me much trouble in an object based programming language where I can deal with data points sequentially but I'm new to SQL and unfamiliar with the methodology used to solve such problems in SQL.
I have been referencing this article (https://www.periscopedata.com/blog/spline-interpolation-in-sql) which provides a framework for the same task I'm trying to accomplish but I believe its using a different SQL distribution which seems to give the ability to create object like items. The code below represents what I have been able to accomplish thus far and am having trouble wrapping my head around how to proceed.
Select [Option Value] As [T] ,[idx],
LAG([Option Value],1) OVER (ORDER BY idx) AS [T-1],
LEAD([Option Value],1) OVER (ORDER BY idx) AS [T+1],
0 As [y2],
0 As [u],
0 AS [p]
INTO #Calc
FROM [#Data]
ORDER BY [idx]
Select *,
([T] - [T-1])/([T+1] - [T-1]) As Sig
FROM #Calc
The input table will have 11 points with a non uniform distribution across the x axis (ex (-0.2,1), (-0.1,1.2), (-0.03,1.6), (0.05,2)) And I hope to create a function that provides the interpolated values between these points.