curve-fitting

find the intersection of abline with fitted curve

折月煮酒 提交于 2019-12-13 04:39:57
问题 I plotted a logistic curve with its fit using the following codes: data:L50 str(L50) 'data.frame': 10 obs. of 3 variables: $ Length.Class: int 50 60 70 80 90 100 110 120 130 140 $ Total.Ind : int 9 20 18 8 4 4 1 0 1 2 $ Mature.Ind : int 0 0 6 5 3 2 1 0 1 2 plot(L50$Mature.Ind/L50$Total.Ind ~ L50$Length.Class, data=L50,pch=20,xlab="Length class(cm)",ylab="Proportion of mature individuals") glm.out<-glm(cbind(L50$Mature.Ind, L50$Total.Ind-L50$Mature.Ind) ~ L50$Length.Class,family=binomial(logit

Fitting a curve in the points

∥☆過路亽.° 提交于 2019-12-13 03:39:33
问题 This is my data: y<-c(1.8, 2, 2.8, 2.9, 2.46, 1.8,0.3,1.1,0.664,0.86,1,1.9) x<- c(1:12) data<-as.data.frame(cbind(y,x)) plot(data$y ~ data$x) I want to fit a curve through these points so that I can generate the intermediate predicted values. I need a curve that goes through the points. I don't care what function it fits. I consulted this link. Fitting a curve to specific data install.packages("rgp") library(rgp) result <- symbolicRegression(y ~ x,data=data,functionSet=mathFunctionSet,

I need a python function that can fit a curve within a parameter space

試著忘記壹切 提交于 2019-12-13 03:24:01
问题 I've been working on a project that uses SciPy's optimize.curve_fit() function to fit a curve to some data by varying 3 parameters, which has been working well. However, I now need to alter the program so that 1 of the parameters has bounds which are a function of another parameter (e.g. when x = 10 ybounds = 1 +/- 0.2 but when x = 11 ybounds = 1.1 +/- 0.2). The only idea I've had so far is to put another optimize.curve_fit() function inside the first one, but this has proved hugely

nls2 treats vectored initial values as single elements, unlike nls

試著忘記壹切 提交于 2019-12-13 03:08:50
问题 I noticed that I can fit parameter vector, as below, using nls . This let's me decide the number of parameters I want to fit. As in the example below; where I am fitting y = k + a_1 x^2 + a_2 x^3 + a_3 x^3 . I can simply change the number of initial values, which change the number of co-efficients to estimate. But, this approach doesn't work with nls2 . It just treats fits the y = k + a_1 * x , three times! My questions is how to get nls2 to determine the number of parameters to fit based on

How do I get minuit.Minuit to fit a gaussian curve to my data in Python?

一曲冷凌霜 提交于 2019-12-13 01:25:36
问题 I am trying to fit a gaussian to some simple data using the minuit.Minuit function but it doesnt change any of my parameters. If anyone can help out I would be very grateful. import numpy as np import minuit xCurve = np.array([0,1,2,3,4,5,6,7,8,9]) yCurve = np.array([0,1,2,3,4,5,4,3,2,1]) def Gaus(a,b,c): return a*np.exp(-((xCurve-b)**2)/(2*c**2)) m = minuit.Minuit(Gaus,a=4.5,b=5,c=0.4) m.printMode=1 m.migrad() m.printMode=0 m.values() a = m.values['a'] b = m.values['b'] c = m.values['c'] d =

Polynomial Least Squares for Image Curve Fitting

十年热恋 提交于 2019-12-12 23:16:32
问题 I am trying to fit a curve to a number of pixels in an image so I can do further processing regarding it's shape. Does anyone know how to implement a least squares method in C/++ preferably using the following parameters: an x array, a y array, and an answers array (the length of the answers array should tell how many coefficients need to be calculated)? 回答1: If this is not some exercise in implementing this yourself, I would suggest you use a ready-made library like GNU gsl. Have a look at

How to fit parametric equations to data points in Python

北城以北 提交于 2019-12-12 19:21:47
问题 I am looking for a way to fit parametric equations to a set of data points, using Python. As a simple example, given is the following set of data points: import numpy as np x_data = np.array([1, 2, 3, 4, 5]) y_data = np.array([2, 0, 3, 7, 13]) Using t as the parameter, I want to fit the following parametric equation to the data points, t = np.arange(0, 5, 0.1) x = a1*t + b1 y = a2*t**2 + b2*t + c2 that is, have Python find the values for the coefficients a1 , b1 , a2 , b2 , c2 that fits (x,y)

Gaussian Curve-fitting algorithm

邮差的信 提交于 2019-12-12 18:19:58
问题 Folks,i have been trying to obtain a Gaussian fit for some data sets which somehow look like a distorted normal distribution.I have been using software to do that. I wonder if i can apply an iterative algorithm to convert these data sets to a Gaussian fitted curve,the standard deviation and mean of the original curve being the inputs.? Any ideas? 回答1: Calculate the mean of the data: mu = 1/N Sum(xi) Calculate the dispersion of the data: sigma = sqrt(1/(N-1) Sum(xi-mu)) Fill in the parameters:

Fitting a distribution given the histogram using scipy

这一生的挚爱 提交于 2019-12-12 18:17:53
问题 I would like to fit a distribution using scipy (in my case, using weibull_min) to my data. Is it possible to do this given the Histogram, and not the data points? In my case, because the histogram has integer bins of size 1, I know that I can extrapolate my data in the following way: import numpy as np orig_hist = np.array([10, 5, 3, 2, 1]) ext_data = reduce(lambda x,y: x+y, [[i]*x for i, x in enumerate(orig_hist)]) In this case, ext_data would hold this: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,

Fitting (a gaussian) with Scipy vs. ROOT et al

会有一股神秘感。 提交于 2019-12-12 16:45:11
问题 I have now multiple times stumbled upon that fitting in python with scipy.curve_fit is somehow a lot harder than with other tools like e.g. ROOT (https://root.cern.ch/) For example, when fitting a gaussian, with scipy I mostly get a straight line: corresponding code: def fit_gauss(y, x = None): n = len(y) # the number of data if x is None: x = np.arange(0,n,1) mean = y.mean() sigma = y.std() def gauss(x, a, x0, sigma): return a * np.exp(-(x - x0) ** 2 / (2 * sigma ** 2)) popt, pcov = curve