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
13
votes
1 answer

trying to display original and fitted data (nls + dnorm) with ggplot2's geom_smooth()

I am exploring some data, so the first thing I wanted to do was try to fit a normal (Gaussian) distribution to it. This is my first time trying this in R, so I'm taking it one step at a time. First I pre-binned my data: myhist = data.frame(size =…
13
votes
3 answers

Errors to fit parameters of scipy.optimize

I use the scipy.optimize.minimize ( https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html ) function with method='L-BFGS-B. An example of what it returns is here above: fun: 32.372210618549758 hess_inv: <6x6 LbfgsInvHessProduct…
Antonio Ragagnin
  • 2,278
  • 4
  • 24
  • 39
13
votes
2 answers

Fit a curve to the boundary of a scatterplot

I'm trying to fit a curve to the boundary of a scatterplot. See this image for reference. I have accomplished a fit already with the following (simplified) code. It slices the dataframe into little vertical strips, and then finds the minimum value…
user6268172
13
votes
1 answer

Python-load data and do multi Gaussian fit

I've been looking for a way to do multiple Gaussian fitting to my data. Most of the examples I've found so far use a normal distribution to make random numbers. But I am interested in looking at the plot of my data and checking if there are 1-3…
astromath
  • 302
  • 1
  • 3
  • 13
13
votes
5 answers

Fit a curve for data made up of two distinct regimes

I'm looking for a way to plot a curve through some experimental data. The data shows a small linear regime with a shallow gradient, followed by a steep linear regime after a threshold value. My data is here: http://pastebin.com/H4NSbxqr I could…
IanRoberts
  • 2,846
  • 5
  • 26
  • 33
13
votes
5 answers

Python curve fit library that allows me to assign bounds to parameters

I'd like to be able to perform fits that allows me to fit an arbitrary curve function to data, and allows me to set arbitrary bounds on parameters, for example I want to fit function: f(x) = a1(x-a2)^a3\cdot\exp(-\a4*x^a5) and say: a2 is in…
jb.
  • 23,300
  • 18
  • 98
  • 136
12
votes
1 answer

Curve Fitting in 2D Images With Missing Data

I have split contours in a image and I want to connect them assuming they are parametrized curves. I was considering some curve fitting or curve tracing - but I do not know, how can I implement it. I have exactly 1 px wide split contours: import…
Foreen
  • 369
  • 2
  • 17
12
votes
1 answer

Scipy optimize raises ValueError despite x0 being within bounds

I'm trying to fit a sigmoid curve onto a small set of points, basically generating a probability curve from a set of observations. I'm using scipy.optimize.curve_fit, with a slightly modified logistic function (so as to be bound completely within…
Iago
  • 121
  • 1
  • 5
12
votes
1 answer

How to obtain the chi squared value as an output of scipy.optimize.curve_fit?

Is it possible to obtain the value of the chi squared as a direct output of scipy.optimize.curve_fit()? Usually, it is easy to compute it after the fit by squaring the difference between the model and the data, weighting by the uncertainties and…
Stefano
  • 359
  • 1
  • 5
  • 16
12
votes
2 answers

How to determine the uncertainty of fit parameters with Python?

I have the following data for x and y: x y 1.71 0.0 1.76 5.0 1.81 10.0 1.86 15.0 1.93 20.0 2.01 25.0 2.09 30.0 2.20 35.0 2.32 40.0 2.47 45.0 2.65 50.0 2.87 55.0 3.16 60.0 3.53 65.0 4.02 70.0 4.69 …
Tom Kurushingal
  • 6,086
  • 20
  • 54
  • 86
12
votes
3 answers

How can I calculate a trend line in PHP?

So I've read the two related questions for calculating a trend line for a graph, but I'm still lost. I have an array of xy coordinates, and I want to come up with another array of xy coordinates (can be fewer coordinates) that represent a…
Stephen
  • 18,827
  • 9
  • 60
  • 98
12
votes
1 answer

How can I draw seamless curve using android graphics ?

I want to draw seamless curve using Android graphics using like followings canvas.quadTo(.....); Android reference said that this method using Bezier curve but this method don't support drawing curve which have more than three points P1 , P2 , P3…
Jindong Jung
  • 457
  • 1
  • 6
  • 19
12
votes
4 answers

Loess Fit and Resulting Equation

I'm a developer up in Portland, OR. I'm wondering if anyone can assist: I'm working on Loess fit models using R, once I have the fit accomplished, I'm looking to back-out the equation of the fitted non-linear curve, wondering if there is a way…
christian miner
  • 149
  • 1
  • 1
  • 4
12
votes
3 answers

Modelling data with a Weibull link function in R

I am trying to model some data that follows a sigmoid curve relationship. In my field of work (psychophysics), a Weibull function is usually used to model such relationships, rather than probit. I am trying to create a model using R and am…
CaptainProg
  • 5,610
  • 23
  • 71
  • 116
11
votes
1 answer

How can I perform a least-squares fitting over multiple data sets fast?

I am trying to make a gaussian fit over many data points. E.g. I have a 256 x 262144 array of data. Where the 256 points need to be fitted to a gaussian distribution, and I need 262144 of them. Sometimes the peak of the gaussian distribution is…
Michael
  • 203
  • 1
  • 4
  • 10