lmfit

Set parameter expression that contains the independent variable in python lmfit

坚强是说给别人听的谎言 提交于 2019-12-08 09:34:59
问题 I have dictionary of parameters with unknown number of those parameters (comes from other function), I looped through the dictionary to add its components to an lmfit models as follows: from lmfit import Parameters fit_params = Parameters() for params_name in dict.keys(): current_param = dict[param_name] fit_params.add(param_name) I wanted to add expression to each parameter with fit_params[param_name].set(expr = 'some_expression_in_function_of_x') where x is my independent variable, when

How to understand F-test based lmfit confidence intervals

断了今生、忘了曾经 提交于 2019-12-08 04:32:29
问题 The excellent lmfit package lets one to run nonlinear regression. It can report two different conf intervals - one based on the covarience matrix the other using a more sophisticated tecnique based on an F-test. Details can be found on the doc. I would like to understand he reasoning behind this technique in depth. Which topics should i read about? Note: i have sufficient stats knowledge 回答1: F stats and other associated methods for obtaining confidence intervals are far superior to a simple

How to understand F-test based lmfit confidence intervals

僤鯓⒐⒋嵵緔 提交于 2019-12-06 14:42:28
The excellent lmfit package lets one to run nonlinear regression. It can report two different conf intervals - one based on the covarience matrix the other using a more sophisticated tecnique based on an F-test. Details can be found on the doc. I would like to understand he reasoning behind this technique in depth. Which topics should i read about? Note: i have sufficient stats knowledge F stats and other associated methods for obtaining confidence intervals are far superior to a simple estimation of te co variance matrix for non-linear models (and others). The primary reason for this is the

How to fit multiple datasets which have a combination of shared and non-shared parameters

故事扮演 提交于 2019-12-04 20:35:08
I'm trying to fit multiple dataset which should have some variables which are shared by between datasets and others which are not. However I'm unsure of the steps I need to take to do this. Below I've shown the approach that I'm trying to use (from 'Issues begin here' doesn't work, and it just for illustrative purposes). In this answer somebody is able to share parameters arcoss datasets is there some way that this could be adapted so that I can also have some non-shared parameters? Does anybody have an idea how I could achieve this, or could somebody suggegst a better approach to acheive the

ValueError: The input contains nan values - from lmfit model despite the input not containing NaNs

守給你的承諾、 提交于 2019-12-04 05:07:29
I'm trying to build a model using lmfit (link to docs) and I can't seems to find out why I keep getting a ValueError: The input contains nan values when I try to fit the model. from lmfit import minimize, Minimizer, Parameters, Parameter, report_fit, Model import numpy as np def cde(t, Qi, at, vw, R, rhob_cb, al, d, r): # t (time), is the independent variable return Qi / (8 * np.pi * ((at * vw)/R) * t * rhob_cb * (np.sqrt(np.pi * ((al * vw)/R * t)))) * \ np.exp(- (R * (d - (t * vw)/ R)**2) / (4 * (al * vw) * t) - (R * r**2)/ (4 * (at * vw) * t)) model_cde = Model(cde) # Allowed to vary model

lmfit minimize fails with ValueError: array is too big

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 09:38:07
问题 I am trying to use the "brute" method to minimize a function of 20 variables. It is failing with a mysterious error. Here is the complete code: import random import numpy as np import lmfit def progress_update(params, iter, resid, *args, **kws): pass #print(resid) def score(params, data = None): parvals = params.valuesdict() M = data X_params = [] Y_params = [] for i in range(M.shape[0]): X_params.append(parvals['x'+str(i)]) for j in range(M.shape[1]): Y_params.append(parvals['y'+str(i)])

lmfit minimize fails with ValueError: array is too big

 ̄綄美尐妖づ 提交于 2019-12-02 05:56:01
I am trying to use the "brute" method to minimize a function of 20 variables. It is failing with a mysterious error. Here is the complete code: import random import numpy as np import lmfit def progress_update(params, iter, resid, *args, **kws): pass #print(resid) def score(params, data = None): parvals = params.valuesdict() M = data X_params = [] Y_params = [] for i in range(M.shape[0]): X_params.append(parvals['x'+str(i)]) for j in range(M.shape[1]): Y_params.append(parvals['y'+str(i)]) return diff(M, X_params, Y_params) def diff(M, X_params, Y_params): total = 0 for i in range(M.shape[0]):

Python and lmfit: How to fit multiple datasets with shared parameters?

旧城冷巷雨未停 提交于 2019-11-27 07:41:46
I would like to use the lmfit module to fit a function to a variable number of data-sets, with some shared and some individual parameters. Here is an example generating Gaussian data, and fitting to each data-set individually: import numpy as np import matplotlib.pyplot as plt from lmfit import minimize, Parameters, report_fit def func_gauss(params, x, data=[]): A = params['A'].value mu = params['mu'].value sigma = params['sigma'].value model = A*np.exp(-(x-mu)**2/(2.*sigma**2)) if data == []: return model return data-model x = np.linspace( -1, 2, 100 ) data = [] for i in np.arange(5): params

Python and lmfit: How to fit multiple datasets with shared parameters?

≯℡__Kan透↙ 提交于 2019-11-26 12:42:47
问题 I would like to use the lmfit module to fit a function to a variable number of data-sets, with some shared and some individual parameters. Here is an example generating Gaussian data, and fitting to each data-set individually: import numpy as np import matplotlib.pyplot as plt from lmfit import minimize, Parameters, report_fit def func_gauss(params, x, data=[]): A = params[\'A\'].value mu = params[\'mu\'].value sigma = params[\'sigma\'].value model = A*np.exp(-(x-mu)**2/(2.*sigma**2)) if data