curve-fitting


Fitting two curves with linear/non-linear regression

孤街醉人 提交于 2020-01-14 07:51:09
问题 I need to fit two curves(which both should belong to cubic functions) into a set of points with JuMP. I've done fitting one curve, but I'm struggling at fitting 2 curves into same dataset. I thought that if I can distribute points to curves - so if each point can only be used once - I can do it like below, but it didn't work. (I know that I can use much more complicated things, I want to keep it simple.) This is a part of my current code: # cubicFunc is a two dimensional array which accepts

scipy.optimize.curve_fit a definite integral function with scipy.integrate.quad

久未见 提交于 2020-01-14 07:04:13
问题 If I have a function that the independent variable is the upper limit of an definite integral of a mathematical model. This mathematical model has the parameters I want to do regression. This mathematical model is nonlinear and can be complicated. How can I solve this? if the output of my function is then be processed, can it be curve_fit? There is a simplified case import scipy.optimize as sp from scipy.integrate import quad import numpy as np number = 100 def f(x,a,b,c): return 500*a*x+b*c

scipy.optimize.curve_fit a definite integral function with scipy.integrate.quad

谁说我不能喝 提交于 2020-01-14 07:03:44
问题 If I have a function that the independent variable is the upper limit of an definite integral of a mathematical model. This mathematical model has the parameters I want to do regression. This mathematical model is nonlinear and can be complicated. How can I solve this? if the output of my function is then be processed, can it be curve_fit? There is a simplified case import scipy.optimize as sp from scipy.integrate import quad import numpy as np number = 100 def f(x,a,b,c): return 500*a*x+b*c

Fitting a quadratic function in python without numpy polyfit

女生的网名这么多〃 提交于 2020-01-13 09:32:56
问题 I am trying to fit a quadratic function to some data, and I'm trying to do this without using numpy's polyfit function. Mathematically I tried to follow this website https://neutrium.net/mathematics/least-squares-fitting-of-a-polynomial/ but somehow I don't think that I'm doing it right. If anyone could assist me that would be great, or If you could suggest another way to do it that would also be awesome. What I've tried so far: import numpy as np import matplotlib.pyplot as plt import pandas

Fitting a sum to data in Python

谁都会走 提交于 2020-01-13 04:44:34
问题 Given that the fitting function is of type: I intend to fit such function to the experimental data (x,y=f(x)) that I have. But then I have some doubts: How do I define my fitting function when there's a summation involved? Once the function defined, i.e. def func(..) return ... is it still possible to use curve_fit from scipy.optimize? Because now there's a set of parameters s_i and r_i involved compared to the usual fitting cases where one has few single parameters. Finally are such cases

Numba jit with scipy

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-13 03:22:08
问题 So I wanted to speed up a program I wrote with the help of numba jit . However jit seems to be not compatible with many scipy functions because they use try ... except ... structures that jit cannot handle (Am I right with this point?) A relatively simple solution I came up with is to copy the scipy source code I need and delete the try except parts (I already know that it will not run into errors so the try part will always work anyways) However I do not like this solution and I am not sure

Difference between Levenberg-Marquardt-Algorithm and ODR

こ雲淡風輕ζ 提交于 2020-01-12 10:39:52
问题 I was able to fit curves to a x/y dataset using peak-o-mat, as shown below. Thats a linear background and 10 lorentzian curves. Since I need to fit many similar curves I wrote a scripted fitting routine, using mpfit.py, which is a Levenberg-Marquardt-Algorithm. However the fit takes longer and, in my opinion, is less accurate than the peak-o-mat result: Starting values Fit result with fixed linear background (values for linear background taken from the peak-o-mat result) Fit result with all

Difference between Levenberg-Marquardt-Algorithm and ODR

醉酒当歌 提交于 2020-01-12 10:38:12
问题 I was able to fit curves to a x/y dataset using peak-o-mat, as shown below. Thats a linear background and 10 lorentzian curves. Since I need to fit many similar curves I wrote a scripted fitting routine, using mpfit.py, which is a Levenberg-Marquardt-Algorithm. However the fit takes longer and, in my opinion, is less accurate than the peak-o-mat result: Starting values Fit result with fixed linear background (values for linear background taken from the peak-o-mat result) Fit result with all

Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000

你说的曾经没有我的故事 提交于 2020-01-12 06:37:07
问题 I want to make an logharitmic fit. But I keep getting the a runtime error: Optimal parameters not found: Number of calls to function has reached maxfev = 1000 I use the following script. Can anyone tell me where I go wrong? I use Spyder an am still a beginner. import math import matplotlib as mpl from scipy.optimize import curve_fit import numpy as np #data F1=[735.0,696.0,690.0,683.0,680.0,678.0,679.0,675.0,671.0,669.0,668.0,664.0,664.0] t1=[1,90000.0,178200.0,421200.0,505800.0,592200.0

How can fit curve on this log data?

青春壹個敷衍的年華 提交于 2020-01-11 13:08:55
问题 I have a problem with a fit curve on this data: On x axes we have a data about wind intensity (m/s), on y axes we have log data (fish catch). I fitted a curve (nls model, Gaussian curve) only on data without logaritm, but when i tried on log data, R tell me: Error in nls(mean.w ~ k * exp(-1/2 * (x.wind - mu)^2/sigma^2), : singolar gradient The model is: mean.w ~ k * exp(-1/2 * (x.wind - mu)^2/sigma^2) , where k,mu and sigma are the parameters to estimate, and mean.w # is y axes (log fish

工具导航Map