data-fitting

Fitting multiple Lorentzians to Brillouin Spectrum using Scipy in Python 3

醉酒当歌 提交于 2021-02-11 17:00:52
问题 I am trying to fit Brillouin Spectra (with several peaks) using scipy.optimize.curve_fit. I have have multiple spectra with several peaks and I am trying to fit them with lorentzian functions (one Lorentzian per peak). I am trying to automate the process for bulk analysis (i.e., using the peak finding algorithm of scipy to get peak positions, peak widths and peaks heights and use them as initial guesses for the fit). I am now working on one spectrum to see if the general idea works, then I

Fitting multiple Lorentzians to Brillouin Spectrum using Scipy in Python 3

杀马特。学长 韩版系。学妹 提交于 2021-02-11 16:58:45
问题 I am trying to fit Brillouin Spectra (with several peaks) using scipy.optimize.curve_fit. I have have multiple spectra with several peaks and I am trying to fit them with lorentzian functions (one Lorentzian per peak). I am trying to automate the process for bulk analysis (i.e., using the peak finding algorithm of scipy to get peak positions, peak widths and peaks heights and use them as initial guesses for the fit). I am now working on one spectrum to see if the general idea works, then I

Least square method in python?

别等时光非礼了梦想. 提交于 2021-02-07 07:30:39
问题 I have these values: T_values = (222, 284, 308.5, 333, 358, 411, 477, 518, 880, 1080, 1259) (x values) C/(3Nk)_values = (0.1282, 0.2308, 0.2650, 0.3120 , 0.3547, 0.4530, 0.5556, 0.6154, 0.8932, 0.9103, 0.9316) (y values) I know they follow the model: C/(3Nk)=(h*w/(k*T))**2*(exp(h*w/(k*T)))/(exp(h*w/(k*T)-1))**2 I also know that k=1.38*10**(-23) and h=6.626*10**(-34) . I have to find the w that best describes the measurement data. I'd like to solve this using the least square method in python,

How to return the fit error in Python curve_fit

百般思念 提交于 2021-01-29 17:31:57
问题 I'm trying to fit function to a data set of an experiment using python. I can get a really good approximation and the fit looks pretty good, but the error given for the parameters is incredibly high and I'm not sure how to fix this. The function looks like this: Function The data consist of the a time data set and a y data set. The variable "ve" is a linear velocity function, that's why in the code it is replaced with "a*x+b". Now the fit looks really good and theoretically the function

Python LMFIT restriction fit parameters

旧城冷巷雨未停 提交于 2021-01-29 10:24:51
问题 I'm trying to fit a function to some data in Python using the LMFIT library for nonlinear functions. It's easy enough, but I want to know if there's a way to restrict some properties of the fitted values. For example, in the following code I fit my data to optimize values A, B and C. But I also want the ratio of A to B to be pi/4 times some integer. Is there a way to impose this restriction? from lmfit import Model import numpy from numpy import cos, sin, pi, linspace Upload data: data =

Fitting an ellipse to a set of 2-D points

落花浮王杯 提交于 2021-01-28 03:58:06
问题 I'm trying to fit an ellipse to a set of points described by x and y coordinates. I found a detailed explanation of how to do it here http://nicky.vanforeest.com/misc/fitEllipse/fitEllipse.html and tried out the code, but it doesn't seem to work. It finds the center correctly, but the angle and axes are completely wrong, as you can see in this image: https://i.imgur.com/VLEeNKQ.png The red points are my data points and the blue aptch is an ellipse drawn from the obtained parameters. Now, the

Fitting an ellipse to a set of 2-D points

元气小坏坏 提交于 2021-01-28 03:54:57
问题 I'm trying to fit an ellipse to a set of points described by x and y coordinates. I found a detailed explanation of how to do it here http://nicky.vanforeest.com/misc/fitEllipse/fitEllipse.html and tried out the code, but it doesn't seem to work. It finds the center correctly, but the angle and axes are completely wrong, as you can see in this image: https://i.imgur.com/VLEeNKQ.png The red points are my data points and the blue aptch is an ellipse drawn from the obtained parameters. Now, the

How to get error estimates for fit parameters in scipy.stats.gamma.fit?

試著忘記壹切 提交于 2020-12-28 20:53:35
问题 I have some which I am fitting to the gamma distribution using scipy.stats. I am able to extract the shape, loc, and scale params and they look reasonable with the data ranges I expect. My question is: is there a way to also get the errors in the parameters? something like the output of curve_fit. NOTE: I don't use curve fit directly because it is not working properly and most of the time is not able to compute the parameters of the gamma distribution. On the other hand, scipy.stats.gamma.fit

Fitting polynomial surface to a 3D dataframe representing family of curves

大兔子大兔子 提交于 2020-06-29 03:32:14
问题 I have a 3-D dataframe representing family of curves: yi=f(xi) which are also depending on a third variable lets say zi (yi=g(xi,zi)) as shown in the graphic below: Family Of Curves The yi data are measurements and each curve is valid on its own. Now I would like to find out a proper way to fit a plane or surface to this data in order to avoid 2-D bilinear data interpolation. In general I am trying to do a similar approach as in the link below: 2D polynomial in Python With the difference that