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
1
vote
1 answer

Matlab - compute percentage residual of the fit against data

I use cftool to fit my data using a custom equation. I could see the fit and also the corresponding residual data of the fit. Since the residuals are absolute values, I am also interested in the percentage deviation with respect to data. Of course,…
SKPS
  • 5,433
  • 5
  • 29
  • 63
1
vote
0 answers

Simultaneous numerical fit of two equations using Numpy least square method

I am trying to fit below mentioned two equations using python leastsq method but am not sure whether this is the right approach. First equation has incomplete gamma function in it while the second one is slightly complex, and along with an…
Prav001
  • 343
  • 1
  • 5
  • 12
1
vote
1 answer

Python curve fitting by specific polynominal

I have a question about the Python curve fitting, I know there's polyfit function in numpy, but if I assign the polynomial as AX^4 + BX^2, how to find this A and B??? import numpy as np import matplotlib.pyplot as plt points = np.array([(1, 1), (2,…
okeyla
  • 65
  • 9
1
vote
1 answer

How can I fit a good Lorentzian on python using scipy.optimize.curve_fit?

I'm trying to fit a Lorentzian function with more than one absorption peak (Mössbauer spectra), but the curve_fit function it not working properly, fitting just few peaks. How can I fit it? Figure: Trying to adjusting multi-Lorentzian Below I show…
Matheus Barbosa
  • 11
  • 1
  • 1
  • 3
1
vote
0 answers

scipy.optimize.curve_fit can't fit non linear function

I have a very non-linear function with two parameters that curve_fit is not able to fit : it fits the first one but do not change the second one. I also get the classical .../.local/lib/python3.6/site-packages/scipy/optimize/minpack.py:794:…
Liris
  • 1,399
  • 3
  • 11
  • 29
1
vote
1 answer

Curve_fit fails on Exponentiated Weibull distribution

I am trying to use scipy.optimize.curve_fit(func,xdata,ydata) To determine the parameters of exponentiated weibull distribution: #define exponentiated weibull distribution def expweib(x,k,lamda,alpha): return…
Lin Qiao
  • 11
  • 1
1
vote
1 answer

Linear combination of temperature sensors curve fitting

I'm trying to do a linear combination of different temperature sensors and curve it them with a strain sensor. What I did is I can fit one temperature sensor with one strain sensor. But I don't know how to do linear combination of different…
andre
  • 731
  • 2
  • 13
  • 27
1
vote
1 answer

Result from function not a proper array of floats using optimize.curve_fit

I have recorded experimental temperatures at five locations from the surface of a solid. At every time step, I want to fit these readings to a theoretical curve defined by my function: Temp_Function_JLT(X,h). X is a multi-dimensional array that…
SimonS
  • 36
  • 6
1
vote
0 answers

Fitting two different data sets by two model functions using symfit

I am trying to fit two data sets by two model functions. I tried to do so using symfit. Here the code: from symfit import variables, parameters, Fit, cos, sin, pi, sqrt, asin import numpy as np n0 = 1.5 data = np.genfromtxt('some data') data = 1000…
Rose
  • 21
  • 1
  • 4
1
vote
2 answers

Python curve fit multiple variable

I am trying to fit a function with multiple variables, my fit_function returns two values, and I need to find best parameters that fit for both values. Here is the sample code import numpy as np from scipy.optimize import curve_fit # Fit function…
user8279969
1
vote
0 answers

Issue in Create Fit: Complex value computed by model function, fitting cannot continue

I am trying to fit a curve using the create fit option. I am using teh NonlinearLeastSquares method I have attached the code below. I am trying to call the create fit using a function as mentioned below. Here z_f1 and y_f1 are matrices of order…
1
vote
0 answers

Optimized multi-data curve fitting

I have a force vs displacement multi-data set with each curve obtained at constant current value. I want to curve fit the data using electromagnetic force equation. F (x,i )=(β(i)^2)/((κ-x)^2). What value of current 'i' should be selected to obtain…
Saad
  • 11
  • 2
1
vote
2 answers

Fitting two sets of data with two different model functions simultaneously giving a unique optimal parameter

I am new to python. Using curve_fit from scipy.optimize, I am trying to fit two sets of data with two different model functions (each for one set of data) simultaneously with the same parameters which should be optimised. Here a sketch of the code…
Rose
  • 21
  • 1
  • 4
1
vote
1 answer

curve_fit fails when using endpoint=False in independent variable

I'm fitting some data (I have hard-coded it here) using a technique described in this question and it seemed to work fine. However, I realized my xdata was not quite what I wanted it to be so I used 'endpoint=False' so that my xdata increased from…
1
vote
1 answer

TypeError after changing the function when using scipy.otimize.least_squares with fixed parameters (Python)

I try to fit data using least_squares from the scipy.optimize package. I had a working semi-solution and changed the fit function and suddenly get a TypeError: () takes exactly 4 arguments (5 given) Here is the relevant part of the…
MaxS
  • 978
  • 3
  • 17
  • 34