Questions tagged [curve-fitting]

Fitting 1-D curve to data points, minimizing pre-defined error/loss function.

From wiki:

Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points.

3428 questions
21
votes
1 answer

Correct fitting with scipy curve_fit including errors in x?

I'm trying to fit a histogram with some data in it using scipy.optimize.curve_fit. If I want to add an error in y, I can simply do so by applying a weight to the fit. But how to apply the error in x (i. e. the error due to binning in case of…
Zollern
  • 305
  • 1
  • 2
  • 11
20
votes
2 answers

Java curve fitting library

I'm hoping to find a simple library that can take a series of 2 dimensional points and give me back a larger series of points that model the curve. Basically, I want to get the effect of curve fitting like this sample from JFreeChart: The problem…
Russell Leggett
  • 8,795
  • 3
  • 31
  • 45
20
votes
3 answers

Exponential curve fitting in R

time = 1:100 head(y) 0.07841589 0.07686316 0.07534116 0.07384931 0.07238699 0.07095363 plot(time,y) This is an exponential curve. How can I fit line on this curve without knowing the formula ? I can't use 'nls' as the formula is unknown…
Si22
  • 231
  • 1
  • 2
  • 3
20
votes
2 answers

fitting multivariate curve_fit in python

I'm trying to fit a simple function to two arrays of independent data in python. I understand that I need to bunch the data for my independent variables into one array, but something still seems to be wrong with the way I'm passing variables when I…
user3133865
  • 205
  • 1
  • 2
  • 4
19
votes
2 answers

Find bezier control-points for curve passing through N points

Considering the following nice solution for finding cubic Bézier control points for a curve passing through 4 points: How to find control points for a BezierSegment given Start, End, and 2 Intersection Pts in C# - AKA Cubic Bezier 4-point…
jwin68
  • 191
  • 1
  • 1
  • 4
18
votes
8 answers

How to calculate the vertex of a parabola given three points

I have three X/Y points that form a parabola. I simply need to calculate what the vertex of the parabola is that goes through these three points. Preferably a quick way as I have to do a LOT of these calculations! The "Ask A Scientist" website…
AZDean
  • 1,774
  • 2
  • 17
  • 24
18
votes
2 answers

Fitting a curve to a power-law distribution with curve_fit does not work

I am trying to find a curve fitting my data that visually seem to have a power law distribution. I hoped to utilize scipy.optimize.curve_fit, but no matter what function or data normalization I try, I am getting either a RuntimeError (parameters…
kpax
  • 621
  • 1
  • 8
  • 18
18
votes
1 answer

Interpolating a closed curve using scipy

I'm writing a python script to interpolate a given set of points with splines. The points are defined by their [x, y] coordinates. I tried to use this code: x = np.array([23, 24, 24, 25, 25]) y = np.array([13, 12, 13, 12, 13]) tck, u =…
sooobus
  • 841
  • 1
  • 9
  • 22
18
votes
3 answers

Using R to fit a Sigmoidal Curve

I have read a post ( Sigmoidal Curve Fit in R ). It was labeled duplicated, but I can't see anything related with the posts. And the answer given for the posts was not enough. I read a webpage Similar to the others, he uses this format to fit the…
FunnyFunkyBuggy
  • 495
  • 1
  • 7
  • 21
18
votes
3 answers

3D curvefitting

I have discrete regular grid of a,b points and their corresponding c values and I interpolate it further to get a smooth curve. Now from interpolation data, I further want to create a polynomial equation for curve fitting. How to fit 3D plot in…
Syeda
  • 341
  • 2
  • 5
  • 14
18
votes
1 answer

OpenCV line fitting algorithm

I'm trying to understand OpenCV fitLine() algorithm. This is fragment of code from OpenCV: icvFitLine2D function - icvFitLine2D I see that there is some random function that chooses points for approximation, then computes distances from points to…
krzych
  • 2,126
  • 7
  • 31
  • 50
17
votes
1 answer

How to get confidence intervals from curve_fit

My question involves statistics and python and I am a beginner in both. I am running a simulation, and for each value for the independent variable (X) I produce 1000 values for the dependent variable (Y). What I have done is that I calculated the…
osmak
  • 315
  • 1
  • 2
  • 10
17
votes
1 answer

Using the absolute_sigma parameter in scipy.optimize.curve_fit

To perform a fit, I am currently using the curve_fit from scipy.optimize. I have calculated the error associated with each of my ydata and I would like to add the calculated sigma = y_errors present in the data to the fit, i.e. minimising sum(…
Srivatsan
  • 9,225
  • 13
  • 58
  • 83
16
votes
1 answer

SciPy curve_fit runtime error, stopping iteration

I am using scipy.optimize.curve_fit() in an iterative way. My problem is that when ever it is unable to fit the parameters the whole program (and thus the iteration) stops, this is the error it gives: RuntimeError: Optimal parameters not found:…
makhlaghi
  • 3,856
  • 6
  • 27
  • 34
16
votes
5 answers

How can I get a cubic bezier curve closest to given points?

Given n points: p0, p1, p2, ..., pn; How can I get the point c1, c2 so that the cubic bezier curve defined by p0, c1, c2, pn closest to the given points? I tried least square method. I wrote this after I read the pdf document in…
EFanZh
  • 2,357
  • 3
  • 30
  • 63