Questions tagged [cubic-spline]

A cubic spline is a smooth 3-order polynomial function that is piecewise-defined, and possesses a high degree of smoothness at the knots where the polynomial pieces connect.

A cubic spline is a smooth 3-order polynomial function that is piecewise-defined, and possesses a high degree of smoothness at the knots where the polynomial pieces connect. The most common cubic splines are Hermite, B-splines and Bezier splines.

Further details can be found at the sites below:

  1. wikipedia
  2. mathematica
170 questions
33
votes
8 answers

How to perform cubic spline interpolation in python?

I have two lists to describe the function y(x): x = [0,1,2,3,4,5] y = [12,14,22,39,58,77] I would like to perform cubic spline interpolation so that given some value u in the domain of x, e.g. u = 1.25 I can find y(u). I found this in SciPy but I…
user112829
  • 491
  • 1
  • 4
  • 7
20
votes
5 answers

Splines with Python (using control knots and endpoints)

I'm trying to do something like the following (image extracted from wikipedia) #!/usr/bin/env python from scipy import interpolate import numpy as np import matplotlib.pyplot as plt # sampling x = np.linspace(0, 10, 10) y = np.sin(x) # spline…
silgon
  • 6,890
  • 7
  • 46
  • 67
13
votes
3 answers

Calculate a 2D spline curve in R

I'm trying to calculate a Bezier-like spline curve that passes through a sequence of x-y coordinates. An example would be like the following output from the cscvn function in Matlab (example link): I believe the (no longer maintained) grid package…
Marc in the box
  • 11,769
  • 4
  • 47
  • 97
12
votes
1 answer

How to smooth interpolation of a float array into a bigger array?

I'm stuck with interpolation in Swift. Can anyone help me with that? I want to interpolate the float array (say [0, 0, 100, 25, 0, 0, 0, 25, 0, 0, 0]) into another array with some given size (for example 128). I found an article (Use Linear…
aibek
  • 161
  • 8
10
votes
1 answer

(Cubic) spline interpolation

I want to perform a (cubic) spline interpolation for population data to "transform" yearly data into quarterly data. I know that there are a fair number of flaws doing so, but I need to do it. Here is an example of my code (using generic input…
Gilles Cosyn
  • 435
  • 2
  • 9
  • 17
9
votes
2 answers

Spline interpolation in 3D in python

I am searching the equivalent Matlab command Vq = interp3(X,Y,Z,V,Xq,Yq,Zq) in Python. In Matlab I can use the method 'spline' interpolation, which I can not find in python for 3D data. There exists scipy.interpolate.griddata, but it doesn't have…
cerv21
  • 311
  • 1
  • 2
  • 11
6
votes
1 answer

Is there a function for not-a-knot cubic splines?

I need to use the "not-a-knot" cubic spline for interpolation in my R scripts. Although there are some R packages for splines, none of them seem to consider the "not-a-knot" type, even if it is said to be a rather "popular" type of cubic spline,…
PabloGregori
  • 147
  • 1
  • 11
6
votes
1 answer

How to specify the number of knot points when using scipy.splprep

I have the following piece of code. It generates the 3-D cubic spline of the given 3-D function given in parametric form. I pretty much adapted this to my case using the online documentation for splprep and splev. But I have some things I don't…
Kid Charlamagne
  • 558
  • 1
  • 10
  • 27
5
votes
2 answers

Remove base line drift with peicewise cubic spline algorithm using MATLAB

I have a signal which I want to remove the basline drift using the picewise cubic spline algorithm in MATLAB. d=load(file, '-mat'); t=1:length(a); xq1=1:0.01:length(a); p = pchip(t,a,xq1); s = spline(t,a,xq1); % figure, hold on,…
Juliette
  • 341
  • 1
  • 11
5
votes
1 answer

How to prevent extrapolation using na.spline()

I'm having trouble with the na.spline() function in the zoo package. Although the documentation explicitly states that this is an interpolation function, the behaviour I'm getting includes extrapolation. The following code reproduces the…
CaptainProg
  • 5,610
  • 23
  • 71
  • 116
4
votes
1 answer

Implement closed B-Spline interpolation of datapoints

I have a set of 3D points which I am trying to interpolate using a pth-degree B-Spline. I have implemented the algorithm described here https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/CURVE-INT-global.html so that the curve passes through…
4
votes
1 answer

Spline interpolation

I'm having difficulties to perform a spline interpolation on the below set: import numpy SOURCE = numpy.array([[1,2,3],[3,4,5], [9,10,11]]) from scipy.interpolate import griddata from scipy.interpolate import interp1d input = [0.5,2,3,6,9,15] The…
Nielsou Akbrg
  • 201
  • 3
  • 13
4
votes
0 answers

Is it solvable to get line's values in chart.js?

I am relatively new at data visualization. I have a line chart, however I know only few points on chart, and these points are linked with Cubic interpolation. I have built a similar chart like that:…
dev1
  • 49
  • 3
3
votes
0 answers

Restricted Cubic Spline Plot of Hazard Ratios

df <- data.frame(PatientID = c("0002" ,"0002", "0005", "0005" ,"0009" ,"0009" ,"0018", "0018" ,"0039" ,"0039" , "0043" ,"0043", "0046", "0046" ,"0048" ,"0048"), time = c( 1961.810 , 929.466 , 978.166, 1005.820 , 925.752 , 969.469 …
Lili
  • 547
  • 6
  • 19
3
votes
1 answer

How to apply dead-time from FOPDT model to a Manipulated Variable in MPC gekko

I'm trying to build a MPC model with previously estimated values of k, tau and theta in a FOPDT equation. I implemented this sugestion to estimate the dead-time using cspline: How to estimate theta value in FOPDT equation using gekko?. However, I…
1
2 3
11 12