bspline

How can I change the number of basis functions when performing B-Spline fitting in scipy (python)?

风流意气都作罢 提交于 2021-02-11 12:23:56
问题 I have a discrete set of points (x_n, y_n) that I would like to approximate/represent as a linear combination of B-spline basis functions. I need to be able to manually change the number of B-spline basis functions used by the method, and I am trying to implement this in python using scipy. To be specific, below is a bit of code that I am using: import scipy spl = scipy.interpolate.splrep(x, y) However, unless I have misunderstood or missed something in the documentation, it seems I cannot

How to extract the function model (polynomials) from scipy.interpolate.splprep()?

不问归期 提交于 2021-02-10 22:10:57
问题 I now have some discrete points, and I interpolated it using the scipy.interpolate.splprep () function (B-spline interpolation) to get a satisfactory smooth curve. Here's the code (draw on the answer to another question) and the result I got. import numpy as np from scipy import interpolate from matplotlib import pyplot as plt # x and y are points sampled randomly x = sampledx y = sampledy # append the starting x,y coordinates x = np.r_[x, x[0]] y = np.r_[y, y[0]] # fit splines to x=f(u) and

Generate a B-Spline basis in SciPy, like bs() in R

北城余情 提交于 2021-02-08 07:39:09
问题 With N 1-dimensional data X, I would like to evaluate each point at K cubic B-splines. In R, there is a simple function with an intuitive API, called bs. There is actually a python package patsy which replicates this, but I can't use that package -- only scipy and such. Having looked through the scipy.interpolate documentation on spline-related functions, the closest I can find is BSpline, or BSpline.basis_element, but how to get just the K basis functions is totally mysterious to me. I tried

Generate a B-Spline basis in SciPy, like bs() in R

廉价感情. 提交于 2021-02-08 07:38:42
问题 With N 1-dimensional data X, I would like to evaluate each point at K cubic B-splines. In R, there is a simple function with an intuitive API, called bs. There is actually a python package patsy which replicates this, but I can't use that package -- only scipy and such. Having looked through the scipy.interpolate documentation on spline-related functions, the closest I can find is BSpline, or BSpline.basis_element, but how to get just the K basis functions is totally mysterious to me. I tried

Get subject-specific peak velocity and age at peak velocity values from linear mixed spline models

喜你入骨 提交于 2021-02-08 04:01:55
问题 I am fitting a linear mixed effects model with a natural spline function for age in order to describe the nonlinear trajectory for a repeated outcome y (bone mineral content in grams) across time ( age in years). How can I solve the spline derivatives to get the velocity curve and estimate for each individual their peak velocity (grams/year) and age at peak velocity (years) from this model? This is the example data dat <- structure(list(id = c(1001L, 1001L, 1001L, 1001L, 1001L, 1002L, 1003L,

Get subject-specific peak velocity and age at peak velocity values from linear mixed spline models

爷,独闯天下 提交于 2021-02-08 04:01:27
问题 I am fitting a linear mixed effects model with a natural spline function for age in order to describe the nonlinear trajectory for a repeated outcome y (bone mineral content in grams) across time ( age in years). How can I solve the spline derivatives to get the velocity curve and estimate for each individual their peak velocity (grams/year) and age at peak velocity (years) from this model? This is the example data dat <- structure(list(id = c(1001L, 1001L, 1001L, 1001L, 1001L, 1002L, 1003L,

Convert a B-Spline into Bezier curves

て烟熏妆下的殇ゞ 提交于 2021-02-07 08:27:22
问题 I have a B-Spline curve. I have all the knots, and the x,y coordinates of the Control Points. I need to convert the B-Spline curve into Bezier curves. My end goal is to be able to draw the shape on an html5 canvas element. The B-Spline is coming from a dxf file which doesn't support Beziers, while a canvas only supports Beziers. I've found several articles which attempt to explain the process, however they are quite a bit over my head and really seem to be very theory intensive. I really need

Convert a B-Spline into Bezier curves

做~自己de王妃 提交于 2021-02-07 08:26:02
问题 I have a B-Spline curve. I have all the knots, and the x,y coordinates of the Control Points. I need to convert the B-Spline curve into Bezier curves. My end goal is to be able to draw the shape on an html5 canvas element. The B-Spline is coming from a dxf file which doesn't support Beziers, while a canvas only supports Beziers. I've found several articles which attempt to explain the process, however they are quite a bit over my head and really seem to be very theory intensive. I really need

scipy.interpolate problems with inputing values

我与影子孤独终老i 提交于 2021-01-29 17:42:42
问题 Currently trying to use scipy's implementation of interpolate to create a uniform cubic B-spline (clamped). When using interpolate.splev() the target (x) value I pass in is changed and the function returns me the x value of a point near but not the same as the target value (and the correct y value for the wrong x value). Anybody got any advice on how I can resolve this problem? Code provided below to recreate problem. Thank you very much in advance :) import numpy as np import random as rd

Create BSpline from knots and coefficients

半世苍凉 提交于 2021-01-27 19:20:23
问题 How can a spline be created if only the points and the coefficients are known? I'm using scipy.interpolate.BSpline here, but am open to other standard packages as well. So basically I want to be able to give someone just those short arrays of coefficients for them to be able to recreate the fit to the data. See the failed red-dashed curve below. import numpy as np import matplotlib.pyplot as plt from scipy.interpolate import BSpline, LSQUnivariateSpline x = np.linspace(0, 10, 50) # x-data y =