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
9
votes
2 answers

Scipy sigmoid curve fitting

I have some data points and would like to find a fitting function, I guess a cumulative Gaussian sigmoid function would fit, but I don't really know how to realize that. This is what I have right now: import numpy as np import pylab from…
Johanna Köllner
  • 103
  • 1
  • 1
  • 7
9
votes
1 answer

Bezier curve fitting with known end points

I want to fit a bezier curve with known end points (p0 and p3) to noisy 2d data. This seems like an easier problem than traditional 4-point bezier curve fitting but still too hard for me to figure out. Can someone point me to existing code or an…
filip
  • 589
  • 1
  • 7
  • 18
9
votes
1 answer

How to compute standard error from ODR results?

I use scipy.odr in order to make a fit with uncertainties on both x and y following this question Correct fitting with scipy curve_fit including errors in x? After the fit I would like to compute the uncertainties on the parameters. Thus I look at…
Ger
  • 9,076
  • 10
  • 37
  • 48
9
votes
1 answer

geom_smooth and exponential fits

I am new to R and I'm having some difficulty plotting an exponential curve using ggplot2. I have a set of data below. DATA X Y x y 1 0.6168111 37.20637 0.6168111 37.20637 2 0.5478698 24.17084 0.5478698…
maherman
  • 93
  • 1
  • 1
  • 4
9
votes
1 answer

Negative exponential fit: curve looks too high

I am trying to fit a negative exponential to some data in R, but the fitted line looks too high compared to the data, whereas the fit I get using Excel's built-in power fit looks more believable. Can someone tell me why? I've tried using the nls()…
ginko
  • 117
  • 1
  • 9
9
votes
1 answer

How to get error estimates for fit parameters in scipy.stats.gamma.fit?

I have some which I am fitting to the gamma distribution using scipy.stats. I am able to extract the shape, loc, and scale params and they look reasonable with the data ranges I expect. My question is: is there a way to also get the errors in the…
iluvatar
  • 872
  • 10
  • 21
9
votes
1 answer

Is there a way to plot a curve of best fit without function? Python

I need to plot a smooth curve of best fit but all the methods I've found use scipy.optimize.curve_fit(), and this requires knowing the function relating x and y. Is there a simpler way to do it for basic scatter plots? What Im trying to get the…
harpreet bains
  • 93
  • 1
  • 1
  • 3
9
votes
1 answer

Getting standard error associated with parameter estimates from scipy.optimize.curve_fit

I am using scipy.optimize.curve_fit to fit a curve to some data i have. The curves, for the most part, seem to fit very well. For some reason, pcov = inf when i print it off. What i really need is to calculate the error associated with the…
user3282375
  • 125
  • 1
  • 1
  • 7
9
votes
2 answers

How to visualize a nonlinear relationship in a scatter plot

I want to visually explore the relationship between two variables. The functional form of the relationship is not visible in dense scatter plots like this: How can I add a lowess smooth to the scatter plot in Python? Or do you have any other…
tobip
  • 465
  • 1
  • 5
  • 18
9
votes
1 answer

What are the weight values to use in numpy polyfit and what is the error of the fit

I'm trying to do a linear fit to some data in numpy. Ex (where w is the number of samples I have for that value, i.e. for the point (x=0, y=0) I only have 1 measurement and the value of that measurement is 2.2, but for the point (1,1) I have 2…
jbssm
  • 6,861
  • 13
  • 54
  • 81
9
votes
5 answers

Pass tuple as input argument for scipy.optimize.curve_fit

I have the following code: import numpy as np from scipy.optimize import curve_fit def func(x, p): return p[0] + p[1] + x popt, pcov = curve_fit(func, np.arange(10), np.arange(10), p0=(0, 0)) It will raise TypeError: func() takes exactly 2…
Yuxiang Wang
  • 8,095
  • 13
  • 64
  • 95
9
votes
7 answers

Plot digitization - scraping sample values from an image of a graph

This isn't really "OCR", since it's not recognizing characters, but it's the same idea applied to curves. Anyone know of an image-processing library or established algorithm for retrieving the values from a (raster) plot image? For instance, in…
endolith
  • 25,479
  • 34
  • 128
  • 192
9
votes
4 answers

How to make a curve smoothing in matlab?

the blue plot is a noisy plot of the original plot(red). Is there any way to approximate the blue plot to nearly red plot?
crack_addict
  • 653
  • 2
  • 8
  • 13
9
votes
2 answers

Linear regression - reduce degrees of freedom

I have a Pandas dataframe with columns like Order Balance Profit cum (%) I'm doing a linear regression model_profit_tr = pd.ols(y=df_closed['Profit cum (%)'], x=df_closed['Order']) The problem with this is that standard model is like…
Femto Trader
  • 1,932
  • 2
  • 20
  • 25
9
votes
7 answers

How to fit the 2D scatter data with a line with C++

I used to work with MATLAB, and for the question I raised I can use p = polyfit(x,y,1) to estimate the best fit line for the scatter data in a plate. I was wondering which resources I can rely on to implement the line fitting algorithm with C++. I…
feelfree
  • 11,175
  • 20
  • 96
  • 167