curve-fitting

Fitting a variable Sinc function in python

岁酱吖の 提交于 2019-12-25 05:08:08
问题 I would like to fit a sinc function to a bunch of datalines. Using a gauss the fit itself does work but the data does not seem to be sufficiently gaussian, so I figured I could just switch to sinc.. I just tried to put together a short piece of self running code but realized, that I probably do not fully understand, how arrays are handled if handed over to a function, which could be part of the reason, why I get error messages calling my program So my code currently looks as follows: from

Python: threading + curve_fit: null argument to internal routine

爷,独闯天下 提交于 2019-12-25 02:18:22
问题 I have got some problems using the following code, which is supposed to do gaussian fits using threads: from PIL import Image import numpy as np from scipy.optimize import curve_fit import threading class myThread (threading.Thread): def __init__(self, index): threading.Thread.__init__(self) self.index = index def run(self): for i in np.arange(n_Bild.shape[1]): curve_fit(self.gauss, x_x, Intensitaet[self.index, ...], p0=(Intensitaet[self.index, i], i, 1, 0)) def gauss(self, x, a, b, c, d):

Rotation invariant curve fitting

自作多情 提交于 2019-12-25 01:56:16
问题 I am trying to build a python application that inspects a part that consists of a straight line followed by a curved arc (as seen in picture). The goal is to find the curvature and arc length of the curved section. My approach so far has been to threshold and skelotinze to produce a series of points. I then use least squares fitting to fit a piecewise mathematical function that is composed of a line and an arc. This works great for level parts. However, if the parts are placed such that the

Scipy MLE fit of a normal distribution

徘徊边缘 提交于 2019-12-25 01:46:18
问题 I was trying to adopt this solution proposed in this thread to determine the parameters of a simple normal distribution. Even though the modifications are minor (based on wikipedia), the result is pretty off. Any suggestion where it goes wrong? import math import numpy as np from scipy.optimize import minimize import matplotlib.pyplot as plt def gaussian(x, mu, sig): return 1./(math.sqrt(2.*math.pi)*sig)*np.exp(-np.power((x - mu)/sig, 2.)/2) def lik(parameters): mu = parameters[0] sigma =

How to fit normal distribution with respect to frequency and intensity in R?

青春壹個敷衍的年華 提交于 2019-12-24 20:17:35
问题 I have a list of data frequency x1,x2,...,xn i.e. 10,20,...,5000. Intensity y1,yx,...,yn 0,0,...,50,60,50,...,0 where I want to fit a normal distribution to the data. I found some website online such as (http://www.di.fc.ul.pt/~jpn/r/distributions/fitting.html) through the procedure like, my_data <- rnorm(250, mean=1, sd=0.45)# unkonwn distribution parameters fit <- fitdistr(my_data, densfun="normal") but obviously, those methods won't work. How to fit the above data to a normal distribution?

How to fit multiple parameters to a differential equation in R?

假如想象 提交于 2019-12-24 17:54:54
问题 With a dataset like this time C 0.1 2.6 0.25 4.817 0.5 6.596 0.75 6.471 1 6.049 1.5 5.314 2 4.611 2.5 4.5 3 4.392 4 4.013 5 3.698 6 3.505 8 3.382 12 2.844 14 2.383 24 1.287 I want to fit this data to a model, which is defined as below twocpt <- function(t, Cc, parms){ with(as.list(parms),{ dC0 <- -k01*C0 dCc <- k01*C0 + k21*Cp -(k12+ke)*Cc dCp <- k12*Cc - k21*Cp list(dCc) }) } I took the reference in this page (http://www.inside-r.org/packages/cran/FME/docs/modCost), and developed the

Linear fit with Math.NET: error in data and error in fit parameters?

孤街浪徒 提交于 2019-12-24 14:31:55
问题 I am trying to use Math.NET to perform a simple linear fit through a small set of datapoints. Using Fit.Line I am very easily able to perform the linear fit and obtain the slope and intercept: Tuple<double, double> result = Fit.Line(xdata, ydata); var intercept = result.Item1; var slope = result.Item2; This is very simple, but what about errors? Errors in y-data My y-data might contain error bars, can Math.NET take these errors into account? There are no errors in x-data, just in y-data.

Matlab :Error in Curve fitting

时光怂恿深爱的人放手 提交于 2019-12-24 14:07:31
问题 I have described a model and i would like to fit in the Curve,I am obtaining an Error in this context , kindly review it. function c = model(t, a1, a2, a3, b1, b2, b3, td, tmax) c = zeros(size(t)); ind = (t > td) & (t < tmax); c(ind) = (t(ind) - td) ./ (tmax - td) * (a1 + a2 + a3); ind = (t >= tmax); c(ind) = a1 * exp(-b1 * (t(ind) - tmax))+ a2 * exp(-b2 * (t(ind) - tmax)) + a3 * exp(-b3 * (t(ind) - tmax)); ft = fittype('model(t, a1, a2, a3, b1, b2, b3, td, tmax)', 'independent','t'); fo =

Sine Wave Curve Fitting in Java

妖精的绣舞 提交于 2019-12-24 13:14:35
问题 I'm using the Apache Commons Math package and I've got the following Sine Wave... 0.90, 0.85, 0.80, 0.83, 0.89 0.90, 0.85, 0.80, 0.83, 0.89 0.90, 0.85, 0.80, 0.83, 0.89 0.90, 0.85, 0.80, 0.83, 0.89 from the above data you can see that the wave has the following attributes... Amplitude = .05 Phase = 0 Frequency = 5 However, when I add my sine wave to a HarmonicFitter like so... HarmonicFitter fitter = new HarmonicFitter(new LevenbergMarquardtOptimizer()); fitter.addObservedPoint(0, 0.90);

Passing variable from an array to scipy.integrate.quad() in python

☆樱花仙子☆ 提交于 2019-12-24 13:10:55
问题 I'm using python to fit function to my dataset. My code worked and fitted function with curve_fit before I added integral scipy.integrate.quad() to the definition of function. I checked why does it give me an error " Supplied function does not return a valid float. " and it turns out that the code works fine if I don't pass a variable from dataset over which I'm fitting my curve. If I set arbitrary value like 5. here: scipy.integrate.quad(args(5.)) instead of Xi it works perfectly again. Here