spline

smoothing surface plot from matrix

依然范特西╮ 提交于 2019-12-07 17:01:06
问题 I'm trying to smooth a 11 X 8 matrix and I can't seem to find a way to do this. I know there are several threads on this but none has helped for my situation. Every approach I've found requires some sort of z ~ x*y approach. In my case I just have a matrix that I would like to simply smooth all of the cell entries to make a smoother surface plot. m [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 29.02530 28.57123 39.02334 38.25483 29.59624 65.01706 41.04771 98.62005 [2,] 24.46539 24.08265 32

MATLAB - interpolating a 2D curve with multiple Y's per X

有些话、适合烂在心里 提交于 2019-12-06 16:29:40
问题 I would like to interpolate a data set, but a given X can have multiple Y's, example given below: A(:,1:2,1)= 95.2343 70.6159 96.4501 71.5573 97.4430 72.7315 98.9743 72.8699 100.0470 71.7690 100.3872 70.2699 100.7797 68.7837 102.1478 68.0814 103.6851 68.0521 105.0307 68.7966 105.8972 70.0666 106.7177 71.3665 107.7095 72.5416 108.9175 73.4924 110.3574 74.0309 111.8943 73.9859 113.3936 73.6446 114.6645 72.7794 115.5911 71.5522 116.2426 70.1591 116.3922 68.6286 116.3503 67.0914 116.7771 65.6147

Python SciPy UnivariateSpline vs R smooth.spline

旧巷老猫 提交于 2019-12-06 16:21:17
I am porting a script written in R over to Python. In R I am using smooth.spline and in Python I am using SciPy UnivariateSpline. They don't produce the same results (even though they are both based on a cubic spline method). Is there a way, or an alternative to UnivariateSpline, to make the Python spline return the same spline as R? I'm a mathematician. I understand the general idea of splines. But not the fine details of their implementation in Python or R. Here is the code in R and then Python. The input data is the same for both. Here is the input data: x = 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0

Parallelization of Piecewise Polynomial Evaluation

邮差的信 提交于 2019-12-06 05:47:26
I am trying to evaluate points in a large piecewise polynomial, which is obtained from a cubic-spline. This takes a long time to do and I would like to speed it up. As such, I would like to evaluate a points on a piecewise polynomial with parallel processes, rather than sequentially. Code: z = zeros(1e6, 1) ; % preallocate some memory for speed Y = rand(11220,161) ; %some data, rand for generating a working example X = 0 : 0.0125 : 2 ; % vector of data sites pp = spline(X, Y) ; % get the piecewise polynomial form of the cubic spline. The resulting structure is large. for t = 1 : 1e6 % big

Python/SciPy: How to get cubic spline equations from CubicSpline

扶醉桌前 提交于 2019-12-06 03:33:35
问题 I am generating a graph of a cubic spline through a given set of data points: import matplotlib.pyplot as plt import numpy as np from scipy import interpolate x = np.array([1, 2, 4, 5]) # sort data points by increasing x value y = np.array([2, 1, 4, 3]) arr = np.arange(np.amin(x), np.amax(x), 0.01) s = interpolate.CubicSpline(x, y) plt.plot(x, y, 'bo', label='Data Point') plt.plot(arr, s(arr), 'r-', label='Cubic Spline') plt.legend() plt.show() How can I get the spline equations from

smoothing surface plot from matrix

有些话、适合烂在心里 提交于 2019-12-06 03:06:54
I'm trying to smooth a 11 X 8 matrix and I can't seem to find a way to do this. I know there are several threads on this but none has helped for my situation. Every approach I've found requires some sort of z ~ x*y approach. In my case I just have a matrix that I would like to simply smooth all of the cell entries to make a smoother surface plot. m [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 29.02530 28.57123 39.02334 38.25483 29.59624 65.01706 41.04771 98.62005 [2,] 24.46539 24.08265 32.89272 32.24494 24.94663 54.80279 34.59906 83.12670 [3,] 28.30679 27.86395 38.05733 37.30784 28.86359 63

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

送分小仙女□ 提交于 2019-12-06 01:48:39
问题 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

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

偶尔善良 提交于 2019-12-05 12:18:48
问题 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

How do I draw a closed curve over a set of points?

醉酒当歌 提交于 2019-12-04 19:54:12
Basically I want to draw a polygon, but I want the edges to appear soft rather than hard. Since the shape of the polygon is important, the edges have to go over the points. I've found monotone cubic splines to be accurate for open curves (i.e., curves that don't wrap around on themselves), but the algorithms I've found precalculate points 0 and N. Can I somehow change them to work with a closed curve? I am implementing this in JavaScript, but pseudo-code would just as well. There is an easy method (developed by Maxim Shemanarev) to construct (usually) good-looking closed Bezier curves set over

Drawing a CatmullRomSpline in libgdx with an endpoint and startpoint

社会主义新天地 提交于 2019-12-04 19:08:14
So my goal is to draw a spline similar to this one (where the line goes through each point): But the spline loops around (from the end point 2 back to the start point): I tried changing the "continuous" boolean in the catmullromspline, but that resulted in only a dot being drawn in the center of the screen. I also ended the line drawing when it hit the last point, but the result was ugly because the line was still curving at the start and end points. I looked everywhere in the source code, and could not find a function that could prevent it from looping. And as far as i know, bezier splines