curve-fitting

new error in old code in numpy exp

穿精又带淫゛_ 提交于 2019-12-12 04:04:16
问题 Recently I was working on some data for which I was able to obtain a curve using curve_fit after saving the plot and the values obtained I returned to the same code later only to find it does not work. #! python 3.5.2 import numpy as np import matplotlib.pyplot as plt import scipy.stats from scipy.optimize import curve_fit data= np.array([ [24, 0.176644513], [27, 0.146382841], [30, 0.129891534], [33, 0.105370908], [38, 0.077820511], [50, 0.047407538]]) x, y = np.array([]), np.array([]) for

Generation of free running list of lapse rate and guess rate for psychometric curve fitting (Scipy)

耗尽温柔 提交于 2019-12-12 03:28:19
问题 As a new user to the curve fitting function from scipy and a relatively new user of python, I am a little confused as to what *popt and p0 exactly generates (with reference to this) So I am trying to plot a psychometric fitting here based of a customized sigmoid function formula that accounts for a guess and lapse rate (Both with values between 0 and 1 to account for participant guessing and performance lapse rates in an experiment. These values would define the fit on the lower and upper end

How to do Scipy curve fitting with error bars and obtain standard errors on fitting parameters?

耗尽温柔 提交于 2019-12-12 03:26:41
问题 I am trying to fit my data points. It looks like the fitting without errors are not that optimistic, therefore now I am trying to fit the data implementing the errors at each point. My fit function is below: def fit_func(x,a,b,c): return np.log10(a*x**b + c) then my data points are below: r = [ 0.00528039,0.00721161,0.00873037,0.01108928,0.01413011,0.01790143,0.02263833, 0.02886089,0.03663713,0.04659512,0.05921978,0.07540126,0.09593949, 0.12190075,0.15501736,0.19713563,0.25041524,0.3185025,0

Trouble when adding 3rd fitting parameter in nls

老子叫甜甜 提交于 2019-12-12 03:03:39
问题 I have some trouble with adding another fitting parameter to my formula. I'm using nlsLM for fitting functions and plyr package fitting in groups. You can see the code below. As well I understood from other questions there are many suggestions on when you obtain singular gradient matrix at initial parameter estimates you can vary the starting values or try to simplify your model by looking for redundant parameters which usually cause troubles. So, I understand that starting parameter is

Error fitting a model in nls

隐身守侯 提交于 2019-12-12 02:36:08
问题 previous answers to similar questions have not help me to solve my problem. I am trying to fit a model y=a1*(1-exp(-a21*Age_WH40))^a3 , where a21=ln(1/a3)/a2 , and Age_WH40 goes from 1 to 40. I've plot the data and a line to get an idea of the starting values plot(MOE_WH40 ~ Age_WH40) lines(ts(8*(1-exp(log(1/3)/5*(1:40)))^3),col="red", lwd=2) fit.nlm_MOE4A.WH <- nls(MOE_WH40 ~ a*(1-exp(log(1/c)/b*Age_WH40))^b, start=list(a=10, b=6, c=2)) but even if I restrict the data to avoid dispersion I

Curve Fitting for equation with two parameters

不打扰是莪最后的温柔 提交于 2019-12-12 01:46:36
问题 I have two arrays: E= [6656400; 13322500; 19980900; 26625600; 33292900; 39942400; 46648900; 53290000] and J=[0.0000000021; 0.0000000047; 0.0000000128; 0.0000000201; 0.0000000659; 0.0000000748; 0.0000001143; 0.0000001397] I want to find the appropriate curve fitting for the above data by applying this equation: J=A0.*(298).^2.*exp(-(W-((((1.6e-19)^3)/(4*pi*2.3*8.854e-12))^0.5).*E.^0.5)./((1.38e-23).*298)) I want to select the starting value of W from 1e-19 I have tried the curve fitting tools

Trouble with curve fitting - lmfit won't produce proper fit to peak data

删除回忆录丶 提交于 2019-12-12 01:39:37
问题 I'm quite new to python and the lmfit model and having some trouble. I want to fit a peak function (something like Gaussian or Voigtian profil) to my experimental data, but it never gives me any good results. Its best fit is a linear function, which kind of describes the base line of my peak profile. The x data for the fitting process are simply numbers running from 0 to 100. Here are my y data: array([ 0.99518284, 0.99449661, 0.99609029, 0.996 , 0.994307 , 0.999693 , 0.99826185, 0.99680361,

MATLAB curve fit display equation on graph

大城市里の小女人 提交于 2019-12-11 19:38:55
问题 Is there a way to display the curvefit equation on the graph produced without having to write it down myself manually every time? By GUI or command-line, anything is okay. Any hacks, some way to get around this? 回答1: Probably easiest to use the fit utility which is the non-graphical equivalent of using curvefit : % sample data x=[1:10]'; y = x+randn(10,1)*0.5; plot(x,y,'o') pars=fit(x,y,'poly1'); pars contains the result of the fit, which you can overlay on the plot above with hold on plot

How can I fit an equation which is not a function

时光总嘲笑我的痴心妄想 提交于 2019-12-11 15:06:57
问题 Given data points in the xy plane, I would like to use scipy.optimize.leastsq to find fit parameters for an ellipse (which cannot be written as a function of x and y). I tried setting the entire equation equal to zero, and then fitting this function, but the fit is failing to converge with error output "The relative error between two consecutive iterates is at most 0.000000." The code is shown below, as well as the output. The fitter clearly does not find any reasonable parameters. My

Fitting an exponent in Python

北战南征 提交于 2019-12-11 14:27:43
问题 I am trying to fit an exponential decay in python. I've tried using scipy.optimize.curve_fit, but it completely fails... x Out[18]: array([ 1.06001000e+04, 1.18721000e+04, 1.32966000e+04, 1.48926000e+04, 1.66801000e+04, 1.86816000e+04, 2.09236000e+04, 2.34351000e+04, 2.62481000e+04, 2.93981000e+04, 3.29261000e+04, 3.68781000e+04, 4.13041000e+04, 4.62611000e+04, 5.18136000e+04, 5.80321000e+04, 6.49966000e+04, 7.27971000e+04, 8.15341000e+04, 9.13196000e+04, 1.02279100e+05, 1.14554100e+05, 1