curve-fitting

Fit sigmoid function (“S” shape curve) to data using Python

ぐ巨炮叔叔 提交于 2020-03-21 12:03:23
问题 I'm trying to fit a sigmoid function to some data I have but I keep getting: ValueError: Unable to determine number of fit parameters. My data looks like this: My code is: from scipy.optimize import curve_fit def sigmoid(x): return (1/(1+np.exp(-x))) popt, pcov = curve_fit(sigmoid, xdata, ydata, method='dogbox') Then I get: --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-5-78540a3a23df> in <module> 2

Javascript array of points how to curve fit?

巧了我就是萌 提交于 2020-02-28 08:19:28
问题 I have an array of points, each point consists of a x and y, the x is a timestamp, y is the actual data. I have created a time series plot in Javascript and I would like to curve fit the data and draw the curve. Can anyone help me to achieve this? My list of points: {fltX: 0, fltY: 55.932203389830505} {fltX: 1.8237082066869301, fltY: 55.932203389830505} {fltX: 3.6474164133738602, fltY: 55.932203389830505} {fltX: 5.47112462006079, fltY: 55.932203389830505} {fltX: 7.2948328267477205, fltY: 81

Curve fitting to coupled ODEs

旧时模样 提交于 2020-02-05 07:12:07
问题 have a question on curve fitting / optimizing. I have three coupled ODEs that descibe a biochemical reaction with a disappearing substrate and two products being formed. I've found examples that have helped me create code to solve the ODEs (below). Now I want to optimize the unknown rate constants (k, k3 and k4) to fit to the experimental data, P, which is a signal from product y[1]. What would be the easiest way of doing this? Thanks. import numpy as np from scipy.integrate import odeint

Curve fitting to coupled ODEs

杀马特。学长 韩版系。学妹 提交于 2020-02-05 07:12:07
问题 have a question on curve fitting / optimizing. I have three coupled ODEs that descibe a biochemical reaction with a disappearing substrate and two products being formed. I've found examples that have helped me create code to solve the ODEs (below). Now I want to optimize the unknown rate constants (k, k3 and k4) to fit to the experimental data, P, which is a signal from product y[1]. What would be the easiest way of doing this? Thanks. import numpy as np from scipy.integrate import odeint

fitting step function with variation in the step location with scipy optimize curve_fit

风格不统一 提交于 2020-02-05 05:21:05
问题 I am trying to fit x y data which look something like x = np.linspace(-2, 2, 1000) a = 0.5 yl = np.ones_like(x[x < a]) * -0.4 + np.random.normal(0, 0.05, x[x < a].shape[0]) yr = np.ones_like(x[x >= a]) * 0.4 + np.random.normal(0, 0.05, x[x >= a].shape[0]) y = np.concatenate((yl, yr)) plt.scatter(x, y, s=2, color='k') I'm using a variation of the Heaviside step function def f(x, a, b): return 0.5 * b * (np.sign(x - a)) and fitting with popt, pcov = curve_fit(f, x, y, p0=p) where p is some

MATLAB curve-fitting, exponential vs linear

被刻印的时光 ゝ 提交于 2020-02-01 03:37:18
问题 I have an array of data which, when plotted, looks like this. I need to use the polyfit command to determine the best fitting exponential for the time roughly between 1.7 and 2.3 . I must also compare this exponential fit to a simple linear fit. I'm given the equation Temp(t) = Temp0 * exp(-(t-t0)/tau) , where t0 is the time corresponding to temperature Temp0 (I can select where to begin my curve-fitting, but it must be confined to the area roughly between 1.7 and 2.3). Here is my attempt. %

Power curve fitting in gnuplot for redundant values

送分小仙女□ 提交于 2020-01-25 01:24:06
问题 I am trying to fit the power curve into my data with following gnuplot code. set termoption enhanced f(x) = a*x**b; fit f(x) 'data.txt' via a,b plot 'data.txt' with points title 'data points', \ f(x) with lines title sprintf('power fit curve f(x) = %.2f·x^{%.2f}', a, b) It works fine for non-redundant data for x axis. (no repeats). But for following type of data: It is fitting the curve only to points of first x value i.e. 1, ( Starred ). and not to the whole dataset. Data: 1 2194* 1 2675* 1

Fitting gaussian to absorbtion line in python

本小妞迷上赌 提交于 2020-01-24 19:23:26
问题 I am trying to fit a gaussian to my data which is taken in a pretty narrow spectral window. We got about 2 points of continuum and then about 10-11 that are part of the line. It should still be possible to fit it I think, but the curve fit is failing each time, and I am not sure why. When running I get RuntimeError: Optimal parameters not found: Number of calls to function has reached maxfev = 800. Code and data: import matplotlib.pyplot as plt from scipy.optimize import curve_fit import

how to use cftool non-interactively in matlab

岁酱吖の 提交于 2020-01-24 12:20:11
问题 Is there any way to use cftool non-interactively. For example, given x, y and the fitting function, calling cftool to generate and returned the fitted data without using opening the toolbox GUI. Thanks 回答1: You can use the fit function that comes with Curve Fitting Toolbox. To find out more, type doc fit . Or you can use cftool interactively, then use Generate Code from the File menu to create a function that uses the fit command to repeat your interactive work programmatically. Use this as a

Applying bounds to specific variable during curve_fit (scipy) leads to an error

ε祈祈猫儿з 提交于 2020-01-24 04:29:09
问题 I am trying to apply bounds onto some of the parameters during curve fitting but I'm getting the following error message when I tried to do so: ValueError: too many values to unpack Doesn't each 2-tuple in the bound command corresponds to x0, k, lapse, guess in the sigmoidscaled function in my case respectively (Ie. corresponding to p0 too)? I then tried playing around in hopes of trying to figure out how it works by reducing the bound command to the following to rid the 'too many values':