curve-fitting

Fitting of experimental data within two different regions

末鹿安然 提交于 2020-01-03 16:54:30
问题 I am fitting a set of experimental data (sample) within two different experimental regions and can be expressed with two mathematical functions as follows: 1st region: y = m*x + c ( the slope can be constrained to zero) 2nd region: y = d*exp(-k*x) the experimental data is shown below and I coded it in python as follows: def func(x, m, c, d, k): return m*x+ c + d*np.exp(-k*x) popt, pcov = curve_fit(func, t, y) Unfortunately, my data is not fitting properly and fitted (returned) parameters do

Fitting of experimental data within two different regions

妖精的绣舞 提交于 2020-01-03 16:54:27
问题 I am fitting a set of experimental data (sample) within two different experimental regions and can be expressed with two mathematical functions as follows: 1st region: y = m*x + c ( the slope can be constrained to zero) 2nd region: y = d*exp(-k*x) the experimental data is shown below and I coded it in python as follows: def func(x, m, c, d, k): return m*x+ c + d*np.exp(-k*x) popt, pcov = curve_fit(func, t, y) Unfortunately, my data is not fitting properly and fitted (returned) parameters do

Fitting SIR model based on least squares

▼魔方 西西 提交于 2020-01-03 02:46:06
问题 I would like to optimize the fitting of SIR model. If I fit the SIR model with only 60 data points I get a "good" result. "Good" means, the fitted model curve is close to data points till t=40. My question is, how can I get a better fit, maybe based on all data points? ydata = ['1e-06', '1.49920166169172e-06', '2.24595472686361e-06', '3.36377954575331e-06', '5.03793663882291e-06', '7.54533628058909e-06', '1.13006564683911e-05', '1.69249500601052e-05', '2.53483161761933e-05', '3

Fitting an exponential decay using a convolution integral -

狂风中的少年 提交于 2020-01-02 18:22:07
问题 I'm fitting the following data where t: time (s), G: counts, f: impulse function: t G f -7200 4.7 0 -6300 5.17 0 -5400 4.93 0 -4500 4.38 0 -3600 4.47 0 -2700 4.4 0 -1800 3.36 0 -900 3.68 0 0 4.58 0 900 11.73 11 1800 18.23 8.25 2700 19.33 3 3600 19.04 0.5 4500 17.21 0 5400 12.98 0 6300 11.59 0 7200 9.26 0 8100 7.66 0 9000 6.59 0 9900 5.68 0 10800 5.1 0 Using the following convolution integral: And more specifically: Where: lambda_1 = 0.000431062 and lambda_2 = 0.000580525 . The code used to

Sinusoidal fitting classes for c#

為{幸葍}努か 提交于 2020-01-02 02:43:20
问题 I am wondering if there is a class for fitting data to a sine curve. I found an algorithm for it here but it would take some time to first understand and then code... Before I go down that road I am wondering if the forum knows of a class that is already created for such mathematical modeling. 回答1: C# does not have a long tradition of scientific computing libraries... My take would be to get one of the numerous numerical computation routine packages (like on of them, or the Numerical Recipes)

Fitting partial Gaussian

杀马特。学长 韩版系。学妹 提交于 2020-01-02 02:35:10
问题 I'm trying to fit a sum of gaussians using scikit-learn because the scikit-learn GaussianMixture seems much more robust than using curve_fit. Problem : It doesn't do a great job in fitting a truncated part of even a single gaussian peak: from sklearn import mixture import matplotlib.pyplot import matplotlib.mlab import numpy as np clf = mixture.GaussianMixture(n_components=1, covariance_type='full') data = np.random.randn(10000) data = [[x] for x in data] clf.fit(data) data = [item for

Pass tuple as input argument for scipy.optimize.curve_fit

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 04:50:08
问题 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 arguments (3 given) . Well, that sounds fair - curve_fit unpact the (0, 0) to be two scalar inputs. So I tried this: popt, pcov = curve_fit(func, np.arange(10), np.arange(10), p0=((0, 0),)) Again, it said: ValueError: object too deep for desired array If I

Using R to fit a Sigmoidal Curve

北战南征 提交于 2019-12-31 22:40:55
问题 I have read a post ( Sigmoidal Curve Fit in R ). It was labeled duplicated, but I can't see anything related with the posts. And the answer given for the posts was not enough. I read a webpage Similar to the others, he uses this format to fit the line: fitmodel <- nls(y~a/(1 + exp(-b * (x-c))), start=list(a=1,b=.5,c=25)) The problem is that, a,b,c were given in most of the cases and I have no clues which set of a,b,c should I use for my set of data. Could someone give me some advice on how to

Scipy curve_fit: how to plot the fitted curve beyond the data points?

末鹿安然 提交于 2019-12-31 07:18:11
问题 I have a number of data points and I used Scipy curve_fit to fit a curve to this data set. I now would like to plot the fit beyond the range of data points and I cannot find out how to do it. Here is a simple example based on an exponential fitting: import numpy as np from scipy.optimize import curve_fit import matplotlib.pyplot as plt def exponential_fit(x, a, b, c): return a*np.exp(-b*x) + c x = np.array([0, 1, 2, 3, 4, 5]) y = np.array([30, 50, 80, 160, 300, 580]) fitting_parameters,

Using R to fit a curve to a dataset using a specific equation

喜夏-厌秋 提交于 2019-12-31 04:24:26
问题 I am using R. I would like to use a specific equation to fit a curve to one of my data sets (attached) > dput(data) structure(list(Gossypol = c(1036.331811, 4171.427741, 6039.995102, 5909.068158, 4140.242559, 4854.985845, 6982.035521, 6132.876396, 948.2418407, 3618.448997, 3130.376482, 5113.942098, 1180.171957, 1500.863038, 4576.787021, 5629.979049, 3378.151945, 3589.187889, 2508.417927, 1989.576826, 5972.926124, 2867.610671, 450.7205451, 1120.955, 3470.09352, 3575.043632, 2952.931863, 349