spline

What does scipy.interpolate.InterpolatedUnivariateSpline.get_coeffs return?

三世轮回 提交于 2019-12-04 12:37:40
I tried the following: spline= interpolate.InterpolatedUnivariateSpline(X, Y, k=3) coefs= spline.get_coeffs() With five values in each of X and Y , I ended up with coefs also having five values. Given that five data points implies four spline sections, and that a cubic polynomial has four coefficients, I would have expected to get four times four= 16 coefficients. Does anyone know how to interpret the values that are returned by the get_coeffs method? Is there any place where this is documented? These are not the coefficients of x, x**2, and so forth: such monomials are ill-suited to

LibGDX guidance - sprite tracing 2D infinite random bezier curve

亡梦爱人 提交于 2019-12-04 11:43:55
I've been able to apply a smooth animation to my sprite and control it using the accelerometer. My sprite is fixed to move left and right along the x-aixs. From here, I need to figure out how to create a vertical infinite wavy line for the sprite to attempt to trace. the aim of my game is for the user to control the sprite's left/right movement with the accelerometer in an attempt to trace the never ending wavy line as best they can, whilst the sprite and camera both move in a vertical direction to simulate "moving along the line." It would be ideal if the line was randomly generated. I've

Plotting estimated HR from coxph object with time-dependent coefficient and splines

百般思念 提交于 2019-12-04 06:10:15
I want to plot the estimated hazard ratio as a function of time in the case of a coxph model with a time-dependent coefficient that is based on a spline term. I created the time-dependent coefficient using function tt , analogous to this example that comes straight from ?coxph : # Fit a time transform model using current age cox = coxph(Surv(time, status) ~ ph.ecog + tt(age), data=lung, tt=function(x,t,...) pspline(x + t/365.25)) Calling survfit(cox) results in an error that survfit does not understand models with a tt term ( as described in 2011 by Terry Therneau ). You can extract the linear

Identify all local extrema of a fitted smoothing spline via R function 'smooth.spline'

拜拜、爱过 提交于 2019-12-04 05:55:36
问题 I have a 2-dimensional data set. I use the R's smooth.spline function to smooth my points graph following an example in this article: https://stat.ethz.ch/R-manual/R-devel/library/stats/html/predict.smooth.spline.html So that I get the spline graph similar to the green line on this picture I'd like to know the X values, where the first derivative of the smoothing spline equals zero (to determine exact minimum or maximum). My problem is that my initial dataset (or a dataset that I could auto

Identifying points in a curve

吃可爱长大的小学妹 提交于 2019-12-04 04:55:30
I feel like this is an easy question... How do you identify coordinates in a figure? I plotted some data, used unireg (the uniReg package) to make a spline curve, and want to pull out the data from a point. library(uniReg) P0mM <- read.table(text=" Time FeuM 0.04 138.8181818 7 1258.636364 14 1320.545455 21 2110.37037 28 13730.37037 35 1550.909091",header=TRUE) z=seq(min(P0mM$Time),max(P0mM$Time),length=201) uf=with(P0mM,unireg(Time,FeuM,g=5,sigma=1)) plot(FeuM~Time,P0mM,ylim=c(0,16000),ylab="Fe2+ uM", xlab="Time", main="0mM P") lines(z,uf$unimod.func(z)) I was able to find the max y value of

finding the area of a closed 2d uniform cubic B-spline

余生长醉 提交于 2019-12-04 01:33:55
I have a list of 2d points which are the control vertices (Dx) for a closed uniform cubic B-spline. I am assuming a simple curve (non-self-intersecting, all control points are distinct). I am trying to find the area enclosed by the curve: If I calculate the knot points (Px), I can treat the curve as a polygon; then I "just" need to find the remaining delta areas, for each segment, between the actual curve and the straight line joining the knot points. I understand that the shape (and therefore area) of a Bspline is invariant under rotation and translation - so for each segment, I can find a

Calculate a bezier spline to get from point to point

此生再无相见时 提交于 2019-12-03 17:20:07
问题 I have 2 points in X,Y + Rotation and I need to calculate a bezier spline (a collection of quadratic beziers) that connects these 2 points smoothly. (see pic) The point represents a unit in a game which can only rotate slowly. So to get from point A to B, it has to take a long path. The attached picture shows quite an exaggeratedly curvy path, but you get the idea. What formulas can I use to calculate such a bezier spline? 回答1: Just saw that I misunderstood your question. Couldn't you use a

Use curved lines in bumps chart

懵懂的女人 提交于 2019-12-03 15:20:27
问题 I'm trying to make a bumps chart (like parallel coordinates but with an ordinal x-axis) to show ranking over time. I can make a straight-line chart very easily: library(ggplot2) set.seed(47) df <- as.data.frame(as.table(replicate(8, sample(4))), responseName = 'rank') df$Var2 <- as.integer(df$Var2) head(df) #> Var1 Var2 rank #> 1 A 1 4 #> 2 B 1 2 #> 3 C 1 3 #> 4 D 1 1 #> 5 A 2 3 #> 6 B 2 4 ggplot(df, aes(Var2, rank, color = Var1)) + geom_line() + geom_point() Wonderful. Now, though, I want to

Curve fitting unsorted points on a plane

邮差的信 提交于 2019-12-03 14:38:50
问题 Question: How do you fit a curve to points on a plane if they aren't single valued? For the example shown, how would one fit a curve (like the black one) to the noisy blue data? It's similar to spline smoothing, but I don't know the order of the data. Matlab would be preferred, but pseudocode is fine. Or a pointer to what the correct terminology for this problem is would be great. Thanks 回答1: Your data look like a two-dimensional parametric plot of (x,y) as a function of some underlying

B Spline confusion

女生的网名这么多〃 提交于 2019-12-03 14:35:21
I realise that there are posts on the topic of B-Splines on this board but those have actually made me more confused so I thought someone might be able to help me. I have simulated data for x-values ranging from 0 to 1. I'd like to fit to my data a cubic spline ( degree = 3 ) with knots at 0, 0.1, 0.2, ... , 0.9, 1. I'd also like to use the B-Spline basis and OLS for parameter estimation (I'm not looking for penalised splines). I think I need the bs function from the spline package but I'm not quite sure and I also don't know what exactly to feed it. I'd also like to plot the resulting