# Tag Info

7

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. import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit t = np.array([33.90, 76.95, 166.65, 302.15, 330.11, 429.82, 533.59, 638....

6

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 to this problem, and published the following manuscripts: T. Birdal, B. Busam, N. Navab, S. Ilic and P. Sturm. "A Minimalist Approach to Type-Agnostic ...

5

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, shown in the figure below, was fitted in Gnuplot using the following commands: h(x) = k * 0.5 * (1.0 - tanh(0.5 * (a * x + b))) + c * x + d fit h(x) 'plot-EV.txt' ...

5

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} \sum_{i=1}^{n} \left( f_{i} - a(bx_{i}+c)^{dy_{i}+e} \right)^{2}$ The Levenberg-Marquardt method is commonly used to solve nonlinear least squares problems ...

5

Numerical judgement of model choice: You model 36 observations with a model consisting of 12 or 13 predictor variables. This is most likely not a good model. Even if you reach a high $R^2_{adj}$, you most likely model a random pattern. Try to compare a computed $AIC$ (Akaike information criterion) or $BIC$ (Bayesian information criterion) of this model to ...

5

The problem is ill-conditioned in the sense that very small changes to the $(y_{i},t_{i})$ data can lead to much larger relative changes in the best fitting parameters. If you do the arithmetic in limited precision (and even IEEE double precision is can be inadequate in practice) then the precision of your floating point arithmetic may not be adequate to ...

5

Chapter 10 of Numerical Analysis (Richard L. Burden, J. Douglas Faires) gives good readable pseudo code for Newtons method. The start parameters are taken from the solution of the linear problem of the log transformed data. (see comment of Christian Clason giving a link (Linear Solution, Mathworld Wolfram) ) while not reached convergence criteria ...

4

Let's use the example (approximate the square root function on $[0.25,1.0]$ with a quartic polynomial) to step through your calculations. I suspect that the code is going to work with only modest changes. Having chosen an initial set of six interpolation points: $$x_k = 0.25, 0.4, 0.55, 0.7, 0.85, 1.0\;\; (k=0,\ldots,5)$$ we proceed to interpolate the ...

4

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\}$ (or the minimizers of an appropriate cost function if equality cannot be achieved). Then, any pair of functions $\{a^*(x)$, $b^*(x)\}$ such that $a^*(x_i)=a_i^*$,...

4

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 bound for the sum as follows. Consider some parameter $\epsilon \in (0,\pi]$. Then for each $n$ the integral $\int_0^{\pi} f_n(x) dx \ge \int_0^{\epsilon} f_n(x) ... 4 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 will converge. I don't know to what, see the long version for an attempt. Let's assume that it is possible to compute$\int_0^{\pi} f_n(x)\text{d}x$exactly. I don'... 3 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{1}{2}\sum_{i=1}^N\left( f_i - F(x_i, \mathbf{m}_i^T \mathbf{a}, \mathbf{m}_i^T \mathbf{b}) \right)^2 + \frac{\alpha}{2} \mathbf{a}^T R \mathbf{a} + \frac{\alpha}... 3 The formula is: m = n + p + 1 m number of knots. n number of control points. p degree. You can check the nurbs book chapter 2 for a complete set of definitions. The Shumaker's book is a more readable reference. There is a paragraph on interpolation also on Tom Lyche and Knut Mørgens's lecture notes. Here you shall find that all the entries in ... 3 I've always relied on physical insights and finding an appropriate nondimensionalization. If your data arises from a physical process where you know the equation or at least the geometry of the problem you may have some luck via the Buckingham pi theorem followed by trial and error. See also this paper: Price, James F. "Dimensional Analysis of Models ... 3 I can report a personal experience on trying to fit fluorescence decays by a sum of two exponentials. We had a quantity of repeated measurements in the same condition, and several different conditions. Non-convexity, and non-uniqueness of the solutions have already been dealt with, the problem is ill-posed, so I will focus here on practical "data" aspects. ... 3 In addition to being ill-posed (as discussed by @BrianBorchers), the problem is also difficult to solve because it is not convex. The original least squares problem is convex because it only contains a sum of squares in the unknowns A,B if a,b are given. But if all four parameters are unknowns, then the exchange A,a \leftrightarrow B,b in four-... 3 Choward already sketched a good approach, I am just going to elaborate. So the equation for a parabola in the plane \mathbb{R}^2 is given by the zero locus of a quadratic equation$$f_a(x,y) = a_{11}x^2 + a_{12}xy + a_{22}y^2 + a_{1}x + a_{2}y + a_{0} = 0,$$where a = (a_{11}, a_{12}, a_{22}, a_{1}, a_{2}, a_{0}) \in \mathbb{R}^6 is the vector of ... 3 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 approximation in OpenCV uses this method. See this for usage and you could also find a MATLAB implementation here or here. 3 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 part of the curve:$$ f(x) = \frac{a}{1 + e^{bx - c} } + d $$[This is similar to the suggested logistic function proposed in the first Answer, but has four ... 2 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 defines discrete segments, discrete circles, discrete planes etc... In your case, there is an algorithm  that has a definition of what a discrete segment is, and ... 2 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). Given the ability to do this, you can make a script fairly easily. Here's one using the hough transform (and associated utilities) in Matlab. It probably requires ... 2 First of all, you can turn the fitting problem for 1 and 3 into an iterative optimization problem if you don't want to deal directly with solving a large system of equations using a matrix approach. For 2, you can use a hash table and design a spatial hash function to map a coordinate to the appropriate subregion, which would be very fast. For 3, given you ... 2 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 (the gradient is J^{T}f, and the Hessian is to first order J^{T}J.) You could also use the Jacobian to compute the gradient of your least squares ... 2 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 command "stats". This command is used for statistic. When it is run, some statistical results will be gotten. If your data file contains two column of data, (... 2 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 software available, like Genie 2000. A paper Evaluation of Peak-Fitting Software for Gamma Spectrum Analysis from 2015 compares a number of these tools. However,... 2 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 division by zero, but gnuplot does not give good error message. Here is corrected version which runs without any error B0P = 4.0; B0 = 30.0 V0 = 36.0; E0 = -535.0; ... 2 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 converged results for the t fitting, while t is actually pretty close to 1, the other parameters are much further away. Its mostly just luck that the t value didn't ... 2 You could use the floor function$$n(E) = \lfloor a + b E\rfloor\, .$$Following is an example with a=5 and b=3. import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit def fun(x, a, b): return a + b*x xdata = np.linspace(-5, 5, 2001, endpoint=False) ydata = np.floor(5 + 3*xdata) popt, pcov = curve_fit(fun, ... 1 Is there a reason you considered the Fourier series? It actually seems fairly simple to compute \frac{\partial T}{\partial t} as a piecewise function of t:$$ \frac{\partial T}{\partial t} = \left\{ \begin{matrix} \frac{\partial c}{\partial t} & c(t) > 0 \\ 0 & c(t) < 0 \end{matrix} \right. = \left\{ \begin{matrix} -\frac{2\pi}{\tau} A \...

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