We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I was trying to fit a 1D cubic spline to sample points, however i don't seem to get correct results. Can someone point me what i am missing here.
import numpy as np from matplotlib import pyplot as plt import pygpuspline.gpuspline as gs import pygpufit.gpufit as gf x = [1,2,3.5,5,6,7,10] y = [0,3,5,7,8,10,12] x1 = np.array(x, dtype=np.float32) y1 = np.array(y, dtype=np.float32) pts = np.array([x,y], dtype=np.float32) coeff = gs.spline_coefficients(pts) pts_flat = np.reshape(y1, (1, y1.size)) spline_fit_initial_parameters = np.array([[1,1,1,1]], dtype=np.float32) tolerance = 1e-30 max_n_iterations = 1000 estimator_id = gf.EstimatorID.LSE parameters_spline, states_spline, chi_squares_spline, n_iterations_spline, time_spline = gf.fit(pts_flat, None, gf.ModelID.SPLINE_1D, spline_fit_initial_parameters, tolerance, max_n_iterations, None, estimator_id, coeff) def cubic_func(x,a,b,c,d): return a * np.power(x,3) + b * np.power(x,2) + c * (x) + d sample_x = np.arange(0,10,0.1) sample_y = [cubic_func(each, *parameters_spline[0]) for each in sample_x] fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10,5)) ax1.plot(x, y) ax2.plot(sample_x,sample_y)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I was trying to fit a 1D cubic spline to sample points, however i don't seem to get correct results. Can someone point me what i am missing here.
The text was updated successfully, but these errors were encountered: