--
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfit-py+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/c0a6bb35-1d5c-4681-ab6b-7dbf4799f78e%40googlegroups.com.
Hi Nicholas,
On Thu, Jan 2, 2020 at 1:14 PM Nicholas Zobrist <nzob...@ucsb.edu> wrote:
Hi,--I have a suggestion for a new feature, and would be happy to work on a PR if it seems useful to people:Models that are linear in their parameters are easy to fit since there is an analytic least squares solution. However, as soon as a model has at least one non-linear parameter, a generic solver is typically required, like those used in lmfit. Having to use a generic solver for these problems can be unfortunate since it can introduce convergence issues and dramatically increase the number of required function evaluations.To avoid this problem, it is possible to fit only the non-linear parameters with a generic solver while solving directly for the linear parameters at each function evaluation. This way the generic solver has a much lower dimensional space to search for the solution.My proposed addition is to include a fit method that implements this algorithm.---I learned about this algorithm in a data analysis course a long time ago and use it quite often in my own work. However, I've never seen any out-of-the-box implementations. I think lmfit would be a good place to add such a method (in my opinion) because it would benefit from the flexibility of the parameters and model objects.Let me know if there is any interest.-Nicholas
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/c0a6bb35-1d5c-4681-ab6b-7dbf4799f78e%40googlegroups.com.
Time resolved spectroscopy data consist of a large number of wavelengths and time points that need to be modeled mathematically in a form that can allow subsequent kinetic modeling of species versus time. The most useful mathematical function is a sum of exponentials in time, each with a unique rate constant and each weighted by amplitudes at all wavelengths. This type of model is often called global analysis and was discussed in an earlier section where the model outcome is named a decay associated difference spectra or DADS. The global analysis takes advantage of many data points in both wavelength and time to reduce the effects of noise in the data set. This occurs because there are many hundreds of wavelengths and time points to provide an overdetermined data set that is fit with a relatively few non-linear parameters in exponential mathematical functions that are weighted by amplitudes at each wavelength (linear parameters). The fitting of such a data set is efficient, as it can be formulated as a matrix math problem with a variable projection algorithm developed by Golub and Pereyra6,7 and improved by Kaufman.8 The algorithm effectively uses a least squares method that is a mix of a very fast linear algorithm for the linear parameter fitting and much slower algorithm for the small number of non-linear parameters such as rate constants in exponentials. The variable projection algorithm was used in an early kinetic study by Nagle9 and many other studies are discussed in a review by vanStokkum.10,11 VanStokkum and his co-workers have developed computer code called TIMP in the R computer language12 and Snellenburg in this group has provided free access to a graphical front end in JAVA called Glotaran (glotaran.org) whose acronym is derived from Global and Target Analysis (GloTarAn),13 where experimental system modeling, such as kinetic modeling of species, is called target analysis by vanStokkum and co-workers.
In our work we have developed our own global fitting code in the Python programming language to allow more complex fitting situations such as pump and repump experiments. We have compared basic fitting results with Glotaran and our Python code and find equivalent parameter outputs. The code follows the mathematical matrix model suggested by Mullen and vanStokkum.12 In our case the variable projection algorithm is created from matrix and non-linear least squares fitting modules in SciPy and NumPy. We also use the parameter class definition in a non-linear fitting package called LMFIT, which enables output parameter statistical analysis and confidence interval analysis. LMFIT uses SciPy algorithms for non-linear fitting and adds a method of bounding parameters in the fitting process, which can be useful in complex cases.
The general approach to an unfamiliar raw data set is to manually make a chirp corrected data set and then run a Singular Value Decomposition (SVD) to get initial guesses for the number of exponentials and their rate constants. The data fitting with our variable projection code usually uses the slower simplex method of Nelder-Mead to ensure not being in a local minimum, and then uses the faster Levenberg-Marquardt algorithm to obtain error estimates. When necessary there is an option to fit the raw data to obtain an optimized chirp correction simultaneous with parameter fitting. The code models the excitation pulse as a Gaussian and the response functions are convoluted with the excitation pulse shape. It is possible to add non-linear response functions or Raman functions at very short time scales, although this is rarely required for our data. In addition, the code can model the pump and delayed repump experiments described in this manuscript. There are a number of options for convenient control of complex fitting cases, where different weighting schemes or parameter bounding can allow better convergence and/or error estimates. The fitting of several hundred wavelengths and 5-6 exponentials can take under a minute on a typical laptop machine with the Nelder-Mead method, and the time is much shorter when working with repeat data sets and the Levenberg-Marquardt algorithm. The Python environment is the Anaconda implementation with the Spyder editor.
(12) Mullen, K. M.; van Stokkum, I. H. M., TIMP: An R package for modeling multi-way spectroscopic measurements. J. Stat. Soft. 2007, 18, http://dx.doi.org/10.18637/jss.v18018.i18603.
(13) Snellenburg, J. J.; Laptenok, S. P.; Seger, R.; Mullen, K. M.; van Stokkum, I. H. M., Glotaran: A Java-Based Graphical User Interface for the R Package TIMP. J. Stat. Soft. 2012, 49, http://dx.doi.org/10.18637/jss.v18049.i18603.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/CA%2B7ESbpcBg3ZUa%3DQ5R%3Diz-0e--zB7jZ3kZNZ12TKqNBYMDnovw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/CAE1vKgpC26PJ8EwxHwVhA7-LwCFOGxkF418Co_RPvzdwnyCfJA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/CA%2B_JPuR%3D8hM%3DeWQuHcNTX%2B%3DF2vwrVKa8WXtw%2BhQsfAddCaMEiw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/CAE1vKgqkrA6%3DLg9nyAWWTpU46eX_J1HUKc2oPEaXn5WxR1ymsg%40mail.gmail.com.
-N
Hi Nicholas,
To unsubscribe from this group and stop receiving emails from it, send an email to lmfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/c0a6bb35-1d5c-4681-ab6b-7dbf4799f78e%40googlegroups.com.
Sure: what do you have in mind? Like, how "non-linear" could a parameter be?--Matt Newville
--
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/CA%2B7ESbpcBg3ZUa%3DQ5R%3Diz-0e--zB7jZ3kZNZ12TKqNBYMDnovw%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/CAE1vKgpC26PJ8EwxHwVhA7-LwCFOGxkF418Co_RPvzdwnyCfJA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/CA%2B_JPuR%3D8hM%3DeWQuHcNTX%2B%3DF2vwrVKa8WXtw%2BhQsfAddCaMEiw%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/CAE1vKgqkrA6%3DLg9nyAWWTpU46eX_J1HUKc2oPEaXn5WxR1ymsg%40mail.gmail.com.
--Matt
On Feb 10, 2020, at 5:19 PM, Till Stensitzki <mail...@gmx.de> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to lmfit-py+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/1fed0c8d-71b3-4529-a4fd-678ee7e75071%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/CAE1vKgrkj8rz2nH8aZkYK_TicBziyn7WyFh9n8j%2BXe7S5gUNyA%40mail.gmail.com.
On Feb 11, 2020, at 1:08 PM, Nicholas Zobrist <nzob...@physics.ucsb.edu> wrote:
Hi Ken and Till,
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/5BCAC595-EB79-49BB-AA36-ECFF1560AA8B%40physics.ucsb.edu.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/CAE1vKgrtkpCfeqiFGTpi%2BfbhYB_M_t4%2BBUJjzEEL6q%3D3SyqF0A%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/CA%2B7ESbrGBF7DNiGP3VuWdjpOMFp%3DDaM4O0xfNrURCd%2BEVxassQ%40mail.gmail.com.