curve-fitting

Fit curve to data, get analytical form, & check when curve crosses threshold

我与影子孤独终老i 提交于 2020-08-10 19:37:20
问题 I have 40 points for each curve and I would like to smooth the function and estimate when the curve crosses a threshold on the y axis. Is there a fitting function that I can easily apply this to, I can use interpolate to plot the new function but I can't figure out how to request the x value for which y = threshold. Unfortunately the curves don't all have the same shape so I can't use scipy.optimize.curve_fit. Thanks! Update: Adding two curves: Curve 1 [942.153,353.081,53.088,125.110,140.851

Fit curve to data, get analytical form, & check when curve crosses threshold

随声附和 提交于 2020-08-10 19:36:55
问题 I have 40 points for each curve and I would like to smooth the function and estimate when the curve crosses a threshold on the y axis. Is there a fitting function that I can easily apply this to, I can use interpolate to plot the new function but I can't figure out how to request the x value for which y = threshold. Unfortunately the curves don't all have the same shape so I can't use scipy.optimize.curve_fit. Thanks! Update: Adding two curves: Curve 1 [942.153,353.081,53.088,125.110,140.851

How do I get the function which transforms an input to be the argument of a Legendre polynomial when using numpy.polynomial.legendre?

给你一囗甜甜゛ 提交于 2020-08-08 04:46:30
问题 # import packages we need later import matplotlib.pyplot as plt import numpy as np What I am doing Inspired by this question & answer, I am fitting a series of Legendre polynomials to a time series: curve1 = \ np.asarray([942.153,353.081,53.088,125.110,140.851,188.170,70.536,-122.473,-369.061,-407.945,88.734,484.334,267.762,65.831,74.010,-55.781,-260.024,-466.830,-524.511,-76.833,-36.779,-117.366,218.578,175.662,185.653,299.285,215.276,546.048,1210.132,3087.326,7052.849,13867.824,27156.939

How do I get the function which transforms an input to be the argument of a Legendre polynomial when using numpy.polynomial.legendre?

℡╲_俬逩灬. 提交于 2020-08-08 04:46:07
问题 # import packages we need later import matplotlib.pyplot as plt import numpy as np What I am doing Inspired by this question & answer, I am fitting a series of Legendre polynomials to a time series: curve1 = \ np.asarray([942.153,353.081,53.088,125.110,140.851,188.170,70.536,-122.473,-369.061,-407.945,88.734,484.334,267.762,65.831,74.010,-55.781,-260.024,-466.830,-524.511,-76.833,-36.779,-117.366,218.578,175.662,185.653,299.285,215.276,546.048,1210.132,3087.326,7052.849,13867.824,27156.939

Curve fitting of complex data

这一生的挚爱 提交于 2020-07-07 06:00:13
问题 I want to fit complex data set with a two functions which shared the same parameters. For this I used def funcReal(x,a,b,c,d): return np.real((a + 1j*b)*(np.exp(1j*k*x - kappa1*x) - np.exp(kappa2*x)) + (c + 1j*d)*(np.exp(-1j*k*x - kappa1*x) - np.exp(-kappa2*x))) def funcImag(x,a,b,c,d): return np.imag((a + 1j*b)*(np.exp(1j*k*x - kappa1*x) - np.exp(kappa2*x)) + (c + 1j*d)*(np.exp(-1j*k*x - kappa1*x) - np.exp(-kappa2*x)))` poptReal, pcovReal = curve_fit(funcReal, x, yReal) poptImag, pcovImag =

Different constraints for fit parameter in lmfit model

[亡魂溺海] 提交于 2020-06-29 05:06:37
问题 I am trying to create a multible voigt/Gaussian/Lorentizan-peak fit function with lmfit. Therefore, I wrote the following Function: def apply_fit_mix_multy(data,modelPeak,peakPos,amplitud,**kwargs): peakPos=np.array(peakPos) Start=kwargs.get('Start',data[0,0]) length_data=len(data)-1 End=kwargs.get('End',data[length_data,0]) StartPeak=kwargs.get('StartPeak',data[0,0]) EndPeak=kwargs.get('EndPeak',data[length_data,0]) BackFunc=kwargs.get('BackFunc',False) BackCut=kwargs.get('BackCut',False)

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

Nonlinear regression with python - what's a simple method to fit this data better?

自古美人都是妖i 提交于 2020-05-13 07:06:33
问题 I have some data that I want to fit so I can make some estimations for the value of a physical parameter given a certain temperature. I used numpy.polyfit for a quadratic model, but the fit isn't quite as nice as I'd like it to be and I don't have much experience with regression. I have included the scatter plot and the model provided by numpy: S vs Temperature; blue dots are experimental data, black line is the model The x axis is temperature (in C) and the y axis is the parameter, which we

Nonlinear regression with python - what's a simple method to fit this data better?

本秂侑毒 提交于 2020-05-13 07:06:09
问题 I have some data that I want to fit so I can make some estimations for the value of a physical parameter given a certain temperature. I used numpy.polyfit for a quadratic model, but the fit isn't quite as nice as I'd like it to be and I don't have much experience with regression. I have included the scatter plot and the model provided by numpy: S vs Temperature; blue dots are experimental data, black line is the model The x axis is temperature (in C) and the y axis is the parameter, which we

How to apply piecewise linear fit for a line with both positive and negative slopes in Python?

扶醉桌前 提交于 2020-04-30 07:35:06
问题 I have data provided in the code which have negative and positive slopes as shown in figure: Using the code applied in this post Fit a curve for data made up of two distinct regimes, I created this code. It works for same slopes either both positive or both negative, but when one is positive and other negative, it is not able to fit the lines properly. from scipy import optimize from scipy import optimize, interpolate from scipy.optimize import curve_fit import matplotlib.pyplot as plt import