spline

Construct a symbolic interpolating spline through given points using SymPy

筅森魡賤 提交于 2019-12-24 02:47:32
问题 Pretend I start with some simple dataset which is defined on R2 follows: DataPointsDomain = [0,1,2,3,4,5] DataPointsRange = [3,6,5,7,9,1] With scipy I can make a lazy polynomial spline using the following: ScipySplineObject = scipy.interpolate.InterpolatedUnivariateSpline( DataPointsDomain, DataPointsRange, k = 1, ) What is the equivalent object in sympy?? SympySplineObject = ...??? (I want to define this object and do analytic sympy manipulation like taking integrals, derivatives, etc... on

Approximate a shape outline using constrained B-splines

↘锁芯ラ 提交于 2019-12-24 00:59:03
问题 I'm looking for a possibility to generate a constrained spline in order to approximate a shape (in my case, a footprint outline). As raw data, I have a table with several hundred xy-coordinate pairs, which have been collected from the boundary of the footprint. The spline should only approximate the data points (the spline does not need to pass the data points). I want to be able to smooth the spline to certain degrees. Also, I need to be able to constrain the spline: Defining several

Writing B-spline as Piecewise Cubic

邮差的信 提交于 2019-12-23 21:15:07
问题 I'm using Scipy's SmoothBivariateSpline class to create a cubic B-spline on bivariate data. I now need to write the piecewise polynomial expression for this spline curve. My mathematical background isn't very strong, so I wasn't able to write my own algorithm for transforming from the t, c, k output of the SmoothBivariateSpline to a polynomial representation. If this is feasible, can you provide pointers on how to approach this? I noticed that Scipy has interpolate.ppform, but I can't find

Difference between quadratic and 2nd order spline interpolation in scipy

♀尐吖头ヾ 提交于 2019-12-23 20:40:46
问题 I am writing functions that will calculate 1d interpolations in python using scipy.interpolate function. using help from documentation I wrote 2 different functions for cubic and cubic spline interpolation # calculate cubic interpolation def linear_interpolation(x): linear = interpolate.interp1d(support_x, support_y, 'cubic') return linear(x) # calculate cubic spline interpolation def cubic_spline_interpolation(x): tck = interpolate.splrep(support_x, support_y) return interpolate.splev(x, tck

Cubic Hermite Spline behaving strangely

丶灬走出姿态 提交于 2019-12-21 13:39:46
问题 I'm attempting to draw a graph using Cubic Hermite Splines. I grabbed the simple code to do so from this interpolation methods page. Here is my code: private float HermiteInterpolate(float y0, float y1, float y2, float y3, float mu) { var mu2 = mu * mu; var a0 = -0.5f * y0 + 1.5f * y1 - 1.5f * y2 + 0.5f * y3; var a1 = y0 - 2.5f * y1 + 2f * y2 - 0.5f * y3; var a2 = -0.5f * y0 + 0.5f * y2; var a3 = y1; return (a0 * mu * mu2) + (a1 * mu2) + (a2 * mu) + a3; } With this data (y-values, from 0-1, x

Splines inside nonlinear least squares in R

自闭症网瘾萝莉.ら 提交于 2019-12-21 05:12:07
问题 Consider a nonlinear least squares model in R, for example of the following form): y ~ theta / ( 1 + exp( -( alpha + beta * x) ) ) (my real problem has several variables and the outer function is not logistic but a bit more involved; this one is simpler but I think if I can do this my case should follow almost immediately) I'd like to replace the term "alpha + beta * x" with (say) a natural cubic spline. here's some code to create some example data with a nonlinear function inside the

Getting the point of a catmull rom spline after a certain distance?

纵饮孤独 提交于 2019-12-21 02:58:09
问题 If I have a Catmull-Rom spline of a certain length how can I calculate its position at a certain distance? Typically to calculate the point in a catmull rom spline you input a value between 0 and 1 to get its position via proportions, how can I do this for distances? For example if my spline is 30 units long how can I get its position at distance 8? The reason I ask is because it seems with catmull rom splines giving points in the [0,1] domain does not guarantee that it will give you the

How to create a cubic bezier curve when given N points in 3D?

ぐ巨炮叔叔 提交于 2019-12-21 02:56:18
问题 So I need to find out where the control points would be for a cubic bezier curve when only knowing points on the curve, the points can lie in 3D. It would be ideal if I could do this for any number of points on the curve. Most of what I have found deals only with 2D, or only for 4 points. 回答1: Let me see if I understand you: you want an interpolating Bezier curve, going through a given set of points P0 P1 ... but drawn as Bezier curves, with a function like bezier4( nstep, Pj, Cj, Dj, Pj+1 )

how do I select the smoothing parameter for smooth.spline()?

岁酱吖の 提交于 2019-12-21 00:41:23
问题 I know that the smoothing parameter(lambda) is quite important for fitting a smoothing spline, but I did not see any post here regarding how to select a reasonable lambda (spar=?), I was told that spar normally ranges from 0 to 1. Could anyone share your experience when use smooth.spline()? Thanks. smooth.spline(x, y = NULL, w = NULL, df, spar = NULL, cv = FALSE, all.knots = FALSE, nknots = NULL, keep.data = TRUE, df.offset = 0, penalty = 1, control.spar = list(), tol = 1e-6 * IQR(x)) 回答1:

Catmull-Rom splines in python

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 14:48:04
问题 Is there a library or function in python to compute Catmull-Rom spline from three points ? What I need in the end are the x,y coordinates of points along the spline, provided that they are always equidistant of a given amount t along the spline (say, the spline curve is 3 units long and I want the x,y coordinates at spline length 0, 1, 2 and 3) Nothing really exciting. I am writing it by myself, but if you find something nice, It would be great for testing (or to save time) 回答1: 3 points ?