Questions tagged [splines]

Smooth polynomial functions that are piecewise-defined.

67 questions
20
votes
3 answers

Is there a Python equivalent to the smooth.spline function in R

The smooth.spline function in R allows a tradeoff between roughness (as defined by the integrated square of the second derivative) and fitting the points (as defined by summing the squares of the residuals). This tradeoff is accomplished by the…
blucena
  • 291
  • 3
  • 6
11
votes
3 answers

How to make a line curve through points

I'm looking for a way to make a line curve through a number of points. It would be preferable to use 3 points although I've considered that in order to give context to the angle of the line entering a point more may be needed to give context to the…
James C
  • 464
  • 1
  • 4
  • 12
10
votes
9 answers

Point Sequence Interpolation

Given an arbitrary sequence of points in space, how would you produce a smooth continuous interpolation between them? 2D and 3D solutions are welcome. Solutions that produce a list of points at arbitrary granularity and solutions that produce…
Nick Retallack
  • 18,986
  • 17
  • 92
  • 114
8
votes
1 answer

Drawing aliased, pixel-perfect 1px splines (Catmull-Rom, specifically)

A brief background: I'm working on a web-based drawing application and need to draw 1px thick splines that pass through their control points. The issue I'm struggling with is that I need to draw each of the pixels between p1 and p2 as if I were…
Xenethyl
  • 3,179
  • 21
  • 31
5
votes
4 answers

scipy.interpolate.UnivariateSpline not smoothing regardless of parameters

I'm having trouble getting scipy.interpolate.UnivariateSpline to use any smoothing when interpolating. Based on the function's page as well as some previous posts, I believe it should provide smoothing with the s parameter. Here is my code: #…
BigChief
  • 246
  • 2
  • 9
5
votes
1 answer

Identify Mathematica interpolation functions from graphs (not Hermite)

I'm reverse-engineering how Mathematica does list interpolation: (* Fortunately, Mathematica WILL interpolate an arbitrary list *) tab = Table[a[i], {i,1,100}] f = Interpolation[tab] (* get the coefficient of each term by setting others to…
Barry Carter
  • 456
  • 1
  • 4
  • 9
5
votes
1 answer

How to plot a Cox hazard model with splines

I have a following model: coxph(Surv(fulength, mortality == 1) ~ pspline(predictor)) where is fulength is a duration of follow-up (including mortality), predictor is a predictor of mortality. The output of the command above is this: …
Oposum
  • 1,155
  • 3
  • 22
  • 38
5
votes
2 answers

What is the R equivalent of matlab's csaps()

csaps() in matlab does a cubic spline according to a particular definition of the smoothing parameter p. Here is some matlab code and its result: % x variable age = 75:99 % y variable diffs = [-39 -2 -167 -21 -13 32 -37…
tim riffe
  • 5,651
  • 1
  • 26
  • 40
4
votes
2 answers

Emulating Excel's "scatter with smooth curve" spline function in Matplotlib for 3 points

I'm trying to emulate Excel's Insert>Scatter>Scatter with smooth lines and markers command in Matplotlib The scipy function interpolate creates a similar effect, with some nice examples of how to simply implement this here: How to draw cubic spline…
Dave
  • 515
  • 1
  • 8
  • 17
4
votes
2 answers

how to use Eigen for B-Splines for noisy sequence data

In the below picture, the spap2 function is used in Matlab to smooth noisy data. The result is very good. Eigen library supports this functionality Splines. I'm looking for an example in Eigen to obtain similar results. For the Matlab, I've used…
CroCo
  • 5,531
  • 9
  • 56
  • 88
4
votes
2 answers

Piecewise constant or 0-degree spline interpolation in Python/Scipy

Despite scipy's documentation indicating that scipy.interpolate.UnivariateSpline will run on order k<=5, under the hood there is an additional constraint for order >=1. Does anyone know of a way to achieve either 0-degree spline or piecewise…
Benjamin
  • 11,560
  • 13
  • 70
  • 119
4
votes
1 answer

Is there any multivariate version of the function interp1 in R?

I am looking for a way to compute the linear interpolation of a multivariate function (of 5 variables) using R. The package akima offer a way to compute the linear interpolation in the bivariate case. Is possible to perform the multivariate linear…
4
votes
2 answers

B-spline curves

I have a set of points which I want to smooth using B-spline curves. My question is how can I implement B-spline curves to smooth these set of points? I want to implement this using c++.
Lakshya Kejriwal
  • 1,340
  • 4
  • 17
  • 27
4
votes
2 answers

How to get confidence interval for smooth.spline?

I have used smooth.spline to estimate a cubic spline for my data. But when I calculate the 90% point-wise confidence interval using equation, the results seems to be a little bit off. Can someone please tell me if I did it wrongly? I am just…
Yu Deng
  • 1,051
  • 4
  • 18
  • 35
3
votes
1 answer

How to plot Splines with ggplot2?

I have some data that i want to make a histogram of. However, I want to represent this histogram with line. I have tried using the freq_poly of the ggplot2. However, the line produced is pretty jagged. I want to know if it is possible to use the…
Sam
  • 7,922
  • 16
  • 47
  • 62
1
2 3 4 5