Skip to main content
7 votes
Accepted

Why is my curve_fit not producing the covariance matrix and the correct values for the unknown variables?

The problem seems to be one of scaling. When I added the jacobian of the function an overflow warning appeared. Thus, I divided the data by their maximum values and it worked. Following is the code. <...
nicoguaro's user avatar
  • 8,622
6 votes
Accepted

Fitting Implicit Surfaces to Oriented Point Sets

I was surprised for not receiving a satisfactory answer to the question above and my investigations showed me that this, indeed is an unexplored area. Hence, I put some effort in developing solutions ...
Tolga Birdal's user avatar
  • 2,339
5 votes
Accepted

What equation should I fit this set of data points to?

You could either fit a logistic function (possibly composing it with a linear function), use segmented regression, or classification and regression trees, among other options. The original data, ...
Juan M. Bello-Rivas's user avatar
5 votes

Finding parameters numerically

In general, you can formulate this as a nonlinear least squares problem. If your values are known at points $(x_{i},y_{i})$, and the known values are $f_{i}$, then you can minimize $\min_{a,b,c,d,e} ...
Brian Borchers's user avatar
5 votes
Accepted

Finding the parameters of a function via curve fit

If you transform your formula and data to the reciprocals, you get $$ \frac1y=\frac1v\left(\frac{k^n}{x^n}+1\right) $$ or $$ y^{-1}=Ax^{-n}+B $$ The graph of this should be an $n$th power parabola ...
Lutz Lehmann's user avatar
  • 6,159
5 votes
Accepted

Weights for equidistant samples in power law fitting

Given that the nature of the curve to be fitted is exponential $A\cdot t^B$ is not exponential. But I think it's fine to worry a little bit here, a curve fit could have an unwanted bias towards a ...
Mikael Öhman's user avatar
4 votes
Accepted

Optimization of known function with respect to two unknown function arguments

Your problem is ill posed in the sense that if a solution exists, it is not unique. To see this, let ($a_i^*$, $b_i^*$), denote a solution of the equation $F(x_i, a_i,b_i)=y_i$, $i\in\{1,\ldots,N\}$ (...
Stelios's user avatar
  • 741
4 votes
Accepted

Computing infinite series with iterated functions

There is a lot to unpack here, and probably this is a better question for math.SE. TL; DR version is: in exact arithmetic, this does not converge; see Maxim Umansky's answer. In FP arithmetic, it ...
Abdullah Ali Sivas's user avatar
4 votes

Computing infinite series with iterated functions

There is no finite limit for this series sum. Note that for each $n$ the function $f_n$ is positive definite, $f_n(x) > 0$ within the semi-open interval $(0,\pi]$, and we can construct the lower ...
Maxim Umansky's user avatar
4 votes
Accepted

Parameter estimation simple theory question related to scipy.optimize.curve_fit

Assuming that everything, individual parameters and function values in $$y_k=f(x,p), ~~~p=(p_1,...,p_d),$$ is scalar, each data point gives one equation $$y_k=f(x_k,p), ~~~k=1,...,N.$$ If you have as ...
Lutz Lehmann's user avatar
  • 6,159
4 votes

Fitting gauss-hermite-parametrization to data?

You're not providing an initial guess for the parameters, and so optimize.curve_fit is defaulting to [1.,1.,1.,1.]. The solver ...
Root of All Things's user avatar
4 votes
Accepted

What are the Exact Rules for Significant Figures, Precision, and Uncertainty?

The rules of significant figures are rule-of-thumb way to communicate errors and should only be seen as a primite first step to talk about uncertainties and measurement errors. You gave the excellent ...
MPIchael's user avatar
  • 3,065
3 votes

Fitting using curve_fit of scipy in python gives totally different answer for 1/t and t

Curve fitting can be very sensitive to your initial guess for each parameter. Because you don't specify a guess in your code, all of these parameters start with a value of 1. Comparing with the ...
Tyberius's user avatar
  • 1,023
3 votes

What is a good library in Python for correlated fits in both the $x$ and $y$ data?

Here is the current code I am using to do correlated fits in the $x$ and $y$ directions. I wrote it from this reference. I adapted it from section 1.A.i and 4.B ...
kηives's user avatar
  • 311
3 votes

Optimization of known function with respect to two unknown function arguments

You could discretize the unknown functions $a$ and $b$, then formulate this as a least squares optimization problem with smoothing regularization. Specifically: $$\min_{\mathbf{a}, \mathbf{b}} \frac{...
Nick Alger's user avatar
  • 3,225
3 votes
Accepted

Gnuplot: How can I fit a range of points (out of the entire data) to a function?

Thanks to Thor, I figured out the solutions to my questions. As he pointed out, the range of the function can be specified in the fit command. In the above data ...
ntk47's user avatar
  • 91
3 votes

What equation should I fit this set of data points to?

An assortment of curves for fitting chemistry examples is presented in these Colby College class notes. Of particular application is the sigmoid response curve with variable "slope" for the central ...
hardmath's user avatar
  • 3,459
3 votes

Fit best polygon to a discrete contour

I am quite surprised why no-one mentioned the famous Douglas Peucker Algorithm for polyline simplification. Since you have contour points in hand, you could benefit from it directly. Contour ...
Tolga Birdal's user avatar
  • 2,339
3 votes
Accepted

Fitting a rectangle-function to a signal in Python

Using the following script, attached to your data, the result obtained is plotted in cyan ...
Cesareo's user avatar
  • 166
3 votes
Accepted

scipy exp model fitting: prevent coefficients blowup

Just take the log of your y-data, $Y=\log(y)$ and do a linear fit. Then from the coefficients of $Y=A\,x+B$ you get $k\!=\!A$ and $h\!=\!e^{-B}$, so that $\log(y) = k\,x - \log(h)$ If you fit your ...
Konstantinos's user avatar
2 votes

Fit best polygon to a discrete contour

There is a approach that uses notions from Discrete Geometry: Discrete Geometry is a discipline that works with objects defined as sets of pixels that try to mimic their standard counterparts. It ...
BrunoLevy's user avatar
  • 2,345
2 votes
Accepted

Fit best polygon to a discrete contour

The Hough Transform is an image processing algorithm for extracting features for an image. The classical version of the algorithm is designed to extract lines from a binary image (such as this). ...
Tyler Olsen's user avatar
  • 1,512
2 votes

Choice of solver/software for global optimisation of cheap black-box function with known derivatives

Since you have the Jacobian matrix, you can apply it within a Gauss-Newton or Levenberg-Marquardt method to effectively approximate the Hessian and gradient of your least squares objective function (...
Brian Borchers's user avatar
2 votes

Gnuplot: How can I determine the maxima of a fit function in gnuplot?

According with this blog the way to find max e min with gnuplot is: With Gnuplot 4.6 the both the x and y coordinate of maximum and minimum points can be find out easily. The method is using new ...
Mauro Vanzetto's user avatar
2 votes

identifying peaks in data

Fitting the peaks of gamma spectra is a typical task in non-destructive analysis of spent fuel or neutron activation analysis. Since these applications are already "quite old", there is some standard ...
GertVdE's user avatar
  • 6,199
2 votes

Fitting line to a staircase function

You could use the floor function $$n(E) = \lfloor a + b E\rfloor\, .$$ Following is an example with $a=5$ and $b=3$. ...
nicoguaro's user avatar
  • 8,622
2 votes
Accepted

Dealing with arrays and fit function in Gnuplot

You must put a dot in all the numbers which are supposed to be floats, so as to be correct while doing division. In gnuplot 2/3 = 0 but 2.0/3.0 = 0.66666..7 In your example, you are suffering from ...
cfdlab's user avatar
  • 3,078
2 votes
Accepted

Averaging oscillatory data

I usually use digital filters, e.g a high order (e.g. 10) low pass Butterworth filter, with the cutoff frequency such that the high frequencies are removed. You should perform a Forward-Backward ...
Laurent90's user avatar
  • 1,973
2 votes
Accepted

Find two lines around which points were randomly generated

This falls into the general class of clustering problems. After the points are clustered it is straight forward to fit the two lines; however, it is possible to directly formulate it as an ...
user9794's user avatar
  • 485

Only top scored, non community-wiki answers of a minimum length are eligible