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
0
votes
1 answer

Fitting a monotonically increasing spline function using Scipy

I want to fit a monotonically increasing smooth spline function for a dataset Code: from scipy.interpolate import interp1d import matplotlib.pyplot as plt x = [0., 0.75, 1.8, 2.25, 3.75, 4.5, 6.45, 6.75, 7.5, 8.325, 10.875, 11.25, 12.525, 12.75,…
0
votes
0 answers

Confidence interval for spline

I am learning about spline variables for logit/Cox model and I generally notice that the confidence bands are narrow when odds/hazard ratio nears 1. What is the possible reason for this? Attaching a sample chart for reference. Edit: The code used…
Pam G
  • 27
  • 4
0
votes
2 answers

Getting predictions from mlrcs function in merlin package in R

I am using the mlrcs function in the merlin package to fit a restricted cubic spline model with a random variable. The model works great, but there does not seem to be any functionality for getting model predictions or contrasts. The "predict"…
0
votes
0 answers

How to Create OR plot with reference being OR=1 from rcs logistic regression

I am trying to create a plot showing odds ratios from a lrm model using spines from the rms package. I've created plots of the log-odds as well as the odds, but for the plot showing odds ratios, the reference starts at an odds ratio of 0 and not an…
Jenny
  • 59
  • 4
0
votes
0 answers

A better 1d interpolation method than Cubic/Quadratic Splines

I was searching for the best interpolation methods that give class C2 functions and found that cubic spline interpolation was the most used. However, when I tested it, although it performed better than Lagrange interpolation, the function still…
0
votes
1 answer

Python - Interpolating a grid in given border

For a project I want a grid like this: 5x5. The points should be movable later but I got that i guess. What i wanna be able to do now is to interpolate for example 100x50 points in this grid of 5x5 marker points but not just linear, CUBIC in both…
JKR
  • 11
  • 3
0
votes
1 answer

Monotone weighted interpolation

Given two points (x1, y1) and (x2, y2), the linear interpolation at x (between x1 and x2) is y = (y1*(x2-x)+y2*(x-x1))/(x2-x1). But when the two points are of different importance, this linear interpolation may not be ideal. Suppose the weights of…
user1424739
  • 11,937
  • 17
  • 63
  • 152
0
votes
1 answer

Interpolating a Time-Series Curve using Cubic Spline

I have the following dataframe: M P 2022-01-10 250 2022-04-03 100 2022-05-26 350 2022-08-01 200 ... ... ^just an example. Basically I have some dates and some prices associated with them. I'm trying to…
0
votes
0 answers

MATLABs interp1 with either pchip or cubic in OpenCV for 1D vector

I need to implement the same logic and values we get in MATLAB using interp1 with 'pchip' or 'cubic' flags and I'm unable to find a fitting replacement in OpenCV other than implementing by myself the cubic interpolation in Numerical Recipes (as…
0
votes
1 answer

Getting Formulas for smooth.splines in R

I have used a stats::smooth.spline function to fit a dataset of 60 (x, y) pairs, and now I need to access the formula which can generate predictions for me, while I have access to the model. Unfortunately the documentation here doesn't help me…
awy
  • 43
  • 6
0
votes
1 answer

Hermite cubic spline absolute error depended on amount of data points

I'm trying to understand how does Hermite spline absolute error change depending on number of data points(n). #include #include #include double f(double x) { return 5*pow(x,9)-19*pow(x,5)+5 ; } double fd(double…
Nickie
  • 35
  • 4
0
votes
1 answer

faster way for cubic spline interpolation

I am using scipy.interpolate.CubicSpline for basically interpolating between three frames, which I have to do for each pixel of the frame: for x in range(input_img.shape[1]): for y in range(input_img.shape[0]): t = (t_frame_k_minus_1 +…
0
votes
0 answers

Extract coordinates between each control point of a Catmull-Rom spline

I'm generating a 2D centripetal Catmull-Rom spline in JavaScript from random control points on a canvas. My intent is to be able to extract a certain defined number (say 10) of intermediate points between the control points of the spline, exactly as…
Riccardo Volpe
  • 1,471
  • 1
  • 16
  • 30
0
votes
1 answer

Can I use any library or Scipy in Python for 4 or n dimensional interpolation?

I've searched a lot on the internet but haven't found an exact method. If someone can point me to a library that can do this, that would be great. I want to find a 4-dimensional cubic spline function such that f(A, B) = C,D. Thanks in advance!
Red
  • 15
  • 2
0
votes
1 answer

Full algorithm (math) of natural cubic splines computation in Python?

I'm interested in full Python code (with math formulas) with all computations needed to calculate natural Cubic Splines from scratch. If possible, fast (e.g. Numpy-based). I created this question only to share my code (as answer) that I programmed…
Arty
  • 14,883
  • 6
  • 36
  • 69