curve-fitting

Fitting two different data sets by two model functions using symfit

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 11:18:57
问题 I am trying to fit two data sets by two model functions. I tried to do so using symfit . Here the code: from symfit import variables, parameters, Fit, cos, sin, pi, sqrt, asin import numpy as np n0 = 1.5 data = np.genfromtxt('some data') data = 1000 * data pos=[] for j in range( len(data) ): pos.append( np.arcsin( np.sin( np.deg2rad( data[j,0]/1000 ) )/1.5 ) ) m1=[] for j in range( len(data) ): m1.append( data[j,1] ) p1=[] for j in range( len(data) ): p1.append(data[j,3]) zero=[] for j in

Scipy Optimal parameters not found: Number of calls to function has reached maxfev = 800

狂风中的少年 提交于 2019-12-24 09:58:39
问题 Trying for the logarithmic fit on the dataset using the codes posted. I keep getting Optimal parameters not found: Number of calls to function has reached maxfev = 800 . Can you help me 1. Resolve the error 2. If the equation I'm using is a good one for the current dataset 3. Suggest any alternative method? Dataset Years Values 0 2000 23.0 1 2001 27.5 2 2002 46.0 3 2003 56.0 4 2004 64.8 5 2005 71.2 6 2006 80.2 7 2007 98.0 8 2008 113.0 9 2009 155.8 10 2010 414.0 11 2011 2297.8 12 2012 3628.4

Fitting multiple parametric equations to curve using nls

不想你离开。 提交于 2019-12-24 07:04:12
问题 I am trying to fit non parametric functions to curve using nls. When I try to fit all the parameters nls was not able to solve the equations. So, I split the equations and applied nls on individual equations and later again as a final fit Here is the data Below is the code for what I did #Readin Data library(readr) library(nls2) Data <- read_csv("data.csv") t<- Data$`Elasped Time (min)` w <-Data$`S2 Weight` t2<- Data$`Elasped Time (min)` w2 <-Data$`S2 Weight` # Parametric functions to be

Matlab cftool producing wrong coefficients

泄露秘密 提交于 2019-12-24 06:40:50
问题 So i have this data x 1.0423 2.8249 3.2016 2.0851 1.0299 4.7397 0.4104 0.5285 0.7102 0.8323 3.1048 2.8685 0.2604 4.6560 3.6433 3.6892 0.3170 4.3022 4.6720 4.9220 y 2.0529 -3.0669 -2.3631 -0.7300 1.4354 2.0260 0.5980 0.5296 1.3405 1.7361 -1.5876 -2.7872 1.0788 1.3677 -0.1355 -1.5755 0.7811 -0.8328 -0.0592 2.0927 And I tried to fit an 8th order polynomial to the data using cftool. These are the results I get which are wrong Linear model Poly8: f(x) = p1*x^8 + p2*x^7 + p3*x^6 + p4*x^5 + p5*x^4 +

Conditional curve fit with scipy?

放肆的年华 提交于 2019-12-24 05:42:17
问题 Let's say I want to fit a straight line to my data recorded with lights off. Now I accidentally left the lights on, and my data has a constant offset from datapoint 101 and onwards. How can I fit this? I've tried to incorporate a condition for x, but I get the error ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() Remember to uncomment the remainder of the code (to encounter the error). import numpy as np from scipy import optimize import

Gnuplot : How to set max number of data points for fit

邮差的信 提交于 2019-12-24 03:59:14
问题 I'm using a gnuplot script that involves several fits, on large data samples. Thus fit has to scale up its max number of data points several times, and it prints on the output Max. number of data points scaled up to: 3072 Max. number of data points scaled up to: 4608 Max. number of data points scaled up to: 6912 Max. number of data points scaled up to: 10368 Max. number of data points scaled up to: 15552 Max. number of data points scaled up to: 23328 I would like to avoid that since it makes

Construct a symbolic interpolating spline through given points using SymPy

筅森魡賤 提交于 2019-12-24 02:47:32
问题 Pretend I start with some simple dataset which is defined on R2 follows: DataPointsDomain = [0,1,2,3,4,5] DataPointsRange = [3,6,5,7,9,1] With scipy I can make a lazy polynomial spline using the following: ScipySplineObject = scipy.interpolate.InterpolatedUnivariateSpline( DataPointsDomain, DataPointsRange, k = 1, ) What is the equivalent object in sympy?? SympySplineObject = ...??? (I want to define this object and do analytic sympy manipulation like taking integrals, derivatives, etc... on

Fit lognormal distribution to already binned data python

拟墨画扇 提交于 2019-12-24 02:40:48
问题 I would like to make a lognormal fit to my already binned data. The bar plot looks like this: Unfortunately, when I try to use the standard lognorm.pdf() the shape of the fitted distribution is very different. I guess it's because my data is already binned. Here's the code: times, data, bin_points = ReadHistogramFile(filename) xmin = 200 xmax = 800 x = np.linspace(xmin, xmax, 1000) shape, loc, scale = stats.lognorm.fit(data, floc=0) pdf = stats.lognorm.pdf(x, shape, loc=loc, scale=scale) area

Curve fitting of complex variable in Matlab

自闭症网瘾萝莉.ら 提交于 2019-12-24 02:09:47
问题 I want to solve the following system of equations shown in the image below, The matrix system where the component of the matrix A is complex numbers with the angle (theta) runs from 0 to 2*pi which has m divisions, and n = 9 . The known value z = x + iy. Suppose the x and y of matrix z is z = 0 1.0148 0.1736 0.9848 0.3420 0.9397 0.5047 0.8742 0.6748 0.8042 0.8419 0.7065 0.9919 0.5727 1.1049 0.4022 1.1757 0.2073 1.1999 0 1.1757 -0.2073 1.1049 -0.4022 0.9919 -0.5727 0.8419 -0.7065 0.6748 -0

How to extract residuals from curvefit

邮差的信 提交于 2019-12-23 17:25:52
问题 I'm using curve fit in Matlab R2016a to find the best fit between two arrays. One array represents a certain value at a given latitude and longitude and the other array represents the date that value was collected. In using the curve fit tool I'm able to find a line of best fit as well as to plot the residuals. The residuals are all I care about-- however, when I export the residuals to the workspace they are represented as one column of numbers. This isn't helpful to me without the