cubic

Spline Interpolation with Python

半城伤御伤魂 提交于 2019-11-28 11:04:39
I wrote the following code to perform a spline interpolation: import numpy as np import scipy as sp x1 = [1., 0.88, 0.67, 0.50, 0.35, 0.27, 0.18, 0.11, 0.08, 0.04, 0.04, 0.02] y1 = [0., 13.99, 27.99, 41.98, 55.98, 69.97, 83.97, 97.97, 111.96, 125.96, 139.95, 153.95] x = np.array(x1) y = np.array(y1) new_length = 25 new_x = np.linspace(x.min(), x.max(), new_length) new_y = sp.interpolate.interp1d(x, y, kind='cubic')(new_x) but I am getting: ValueError: A value in x_new is below the interpolation range. in interpolate.py Any help would be appreciated. From the scipy documentation on scipy

Cubic Regression (best fit line) in JavaScript

岁酱吖の 提交于 2019-11-28 06:22:36
问题 I'm having the worst time trying to find a JavaScript code that could allow me to do cubic regressions. Would write it myself, but my understanding of polynomial math is, well, suboptimal. So, here's what I'm looking for. Given an input of an array of arrays, where the internal array would be [x,y], the function would give me an output in the form of an array with four parameters - [a,b,c,d], where a, b, c, and d are parameters of the equation y = ax^3 + bx^2 + cx + d. Example: Input is an

Find the root of a cubic function

ぐ巨炮叔叔 提交于 2019-11-28 02:18:43
Here is the thing. I am trying to use fsolve function in Python to find the root of a cubic function. This cubic function has a parameter, deltaW . What I do is change this parameter deltaW from -50 to 50 , and find the root of the cubic function at the same time. Below is my script: from scipy.optimize import fsolve import matplotlib.pyplot as plt import numpy as np import pylab g = 5.61 gamma = 6.45 kappa = 6.45 J = 6.45 rs = 1.0 #There are just parameters m = 5.0*10**(-11) wm = 2*3.14*23.4 X = [] X1 = [] def func(x): #Define the cubic function I need to solve A = 1j*g**2*(kappa + 1j*deltaW)

Resolution independent cubic bezier drawing on GPU (Blinn/Loop)

送分小仙女□ 提交于 2019-11-27 20:19:18
Based on the following resources, I have been trying to get resolution independent cubic bezier rendering on the GPU to work: GPU Gems 3 Chapter 25 Curvy Blues Resolution Independent Curve Rendering using Programmable Graphics Hardware But as stated in the Curvy Blues website, there are errors in the documents on the other two websites. Curvy Blues tells me to look at the comments, but I don't seem to be able to find those comments. Another forum somewhere tells me the same, I don't remember what that forum was. But there is definitely something I am missing. Anyway, I have tried to regenerate

Solving a cubic equation

不打扰是莪最后的温柔 提交于 2019-11-27 18:16:57
问题 As part of a program I'm writing, I need to solve a cubic equation exactly (rather than using a numerical root finder): a*x**3 + b*x**2 + c*x + d = 0. I'm trying to use the equations from here. However, consider the following code (this is Python but it's pretty generic code): a = 1.0 b = 0.0 c = 0.2 - 1.0 d = -0.7 * 0.2 q = (3*a*c - b**2) / (9 * a**2) r = (9*a*b*c - 27*a**2*d - 2*b**3) / (54*a**3) print "q = ",q print "r = ",r delta = q**3 + r**2 print "delta = ",delta # here delta is less

Create easy function 40% off set

落花浮王杯 提交于 2019-11-27 08:50:30
问题 I have animation follows this timing function: cubic-bezier(0.25, 0.1, 0.25, 1.0) I want to mod this function so i just get the ending 40% of it. To make things easy lets just say I want the end 50% of the function. How can I do this. So graphically this is what it is: https://developer.mozilla.org/files/3429/cubic-bezier,ease.png and I want to to make a cubic-bezier with parameters such that graphically we only see the top portion, so what we see from 0.5 to 1 (on the yaxist) porition of

Spline Interpolation with Python

你离开我真会死。 提交于 2019-11-27 03:20:34
问题 I wrote the following code to perform a spline interpolation: import numpy as np import scipy as sp x1 = [1., 0.88, 0.67, 0.50, 0.35, 0.27, 0.18, 0.11, 0.08, 0.04, 0.04, 0.02] y1 = [0., 13.99, 27.99, 41.98, 55.98, 69.97, 83.97, 97.97, 111.96, 125.96, 139.95, 153.95] x = np.array(x1) y = np.array(y1) new_length = 25 new_x = np.linspace(x.min(), x.max(), new_length) new_y = sp.interpolate.interp1d(x, y, kind='cubic')(new_x) but I am getting: ValueError: A value in x_new is below the

Find the root of a cubic function

不打扰是莪最后的温柔 提交于 2019-11-26 22:10:49
问题 Here is the thing. I am trying to use fsolve function in Python to find the root of a cubic function. This cubic function has a parameter, deltaW . What I do is change this parameter deltaW from -50 to 50 , and find the root of the cubic function at the same time. Below is my script: from scipy.optimize import fsolve import matplotlib.pyplot as plt import numpy as np import pylab g = 5.61 gamma = 6.45 kappa = 6.45 J = 6.45 rs = 1.0 #There are just parameters m = 5.0*10**(-11) wm = 2*3.14*23.4

Resolution independent cubic bezier drawing on GPU (Blinn/Loop)

ぃ、小莉子 提交于 2019-11-26 20:22:39
问题 Based on the following resources, I have been trying to get resolution independent cubic bezier rendering on the GPU to work: GPU Gems 3 Chapter 25 Curvy Blues Resolution Independent Curve Rendering using Programmable Graphics Hardware But as stated in the Curvy Blues website, there are errors in the documents on the other two websites. Curvy Blues tells me to look at the comments, but I don't seem to be able to find those comments. Another forum somewhere tells me the same, I don't remember

Proper implementation of cubic spline interpolation

末鹿安然 提交于 2019-11-26 06:08:32
问题 I was using one of the proposed algorithms out there but the results are very bad. I implemented the wiki algorithm in Java (code below). x(0) is points.get(0) , y(0) is values[points.get(0)] , α is alfa and μ is mi . The rest is the same as in the wiki pseudocode. public void createSpline(double[] values, ArrayList<Integer> points){ a = new double[points.size()+1]; for (int i=0; i <points.size();i++) { a[i] = values[points.get(i)]; } b = new double[points.size()]; d = new double[points.size(