data-fitting

Python power law fit with upper limits & asymmetric errors in data using ODR

南笙酒味 提交于 2019-12-04 12:01:08
问题 I'm trying to fit some data to a power law using python. The problem is that some of my points are upper limits, which I don't know how to include in the fitting routine. In the data, I have put the upper limits as errors in y equal to 1, when the rest is much smaller. You can put this errors to 0 and change the uplims list generator, but then the fit is terrible. The code is the following: import numpy as np import matplotlib.pyplot as plt from scipy.odr import * # Initiate some data x = [1

Sine wave frequency fitting

痴心易碎 提交于 2019-12-04 11:10:23
This question is based on a previous similar question. I have the following equation and an adjusted (some random data): 0.44*sin(N* 2*PI/30) I am trying to use the FFT to get the frequency from the data generated. However the frequency ends up being close but not equal to the frequency (which makes the wave a bit larger than intended) The frequencies that are at the maximum for the FFT is 7hz, however the expected frequency is (30/2PI) 4.77hz. I've included a graph of the FFT and plotted values. The code I am using is: [sampleFFTValues sFreq] = positiveFFT(sampledata, 1); sampleFFTValues =

Meaning of validation_steps in Keras Sequential fit_generator parameter list

拟墨画扇 提交于 2019-12-03 11:02:35
问题 I am using Keras with a Tensorflow backend in Python. To be more precise tensorflow 1.2.1 and its build-in contrib.keras lib. I want to use the fit_generator method of a Sequential model object, but I am confused with what I should pass as the method-parameters. From reading the doc here I got the following information: generator : a python training data batch generator; endlessly looping over its training data validation_data : - in my case - a python validation data batch generator; the doc

Fitting data with integral function

懵懂的女人 提交于 2019-12-03 09:23:12
问题 When using curve_fit from scipy.optimize to fit a some data in python, one first defines the fitting function (e.g. a 2nd order polynomial) as follows: def f(x, a, b): return a*x**2+b*x And then proceeds with the fitting popt, pcov = curve_fit(f,x,y) But the question is now, how does one go about defining the function in point 1. if the function contains an integral (or a discrete sum), e.g.: The experimental data is still given for x and f(x), so point 2. would be similar I imagine once I

R: Robust fitting of data points to a Gaussian function

允我心安 提交于 2019-12-03 08:47:35
I need to do some robust data-fitting operation. I have bunch of (x,y) data, that I want to fit to a Gaussian (aka normal) function. The point is, I want to remove the ouliers. As one can see on the sample plot below, there is another distribution of data thats pollutting my data on the right, and I don't want to take it into account to do the fitting (i.e. to find \sigma, \mu and the overall scale parameter). R seems to be the right tool for the job, I found some packages ( robust , robustbase , MASS for example) that are related to robust fitting. However, they assume the user already has a

Python power law fit with upper limits & asymmetric errors in data using ODR

瘦欲@ 提交于 2019-12-03 07:55:33
I'm trying to fit some data to a power law using python. The problem is that some of my points are upper limits, which I don't know how to include in the fitting routine. In the data, I have put the upper limits as errors in y equal to 1, when the rest is much smaller. You can put this errors to 0 and change the uplims list generator, but then the fit is terrible. The code is the following: import numpy as np import matplotlib.pyplot as plt from scipy.odr import * # Initiate some data x = [1.73e-04, 5.21e-04, 1.57e-03, 4.71e-03, 1.41e-02, 4.25e-02, 1.28e-01, 3.84e-01, 1.15e+00] x_err = [1e-04,

Fitting data with integral function

情到浓时终转凉″ 提交于 2019-12-03 02:36:12
When using curve_fit from scipy.optimize to fit a some data in python, one first defines the fitting function (e.g. a 2nd order polynomial) as follows: def f(x, a, b): return a*x**2+b*x And then proceeds with the fitting popt, pcov = curve_fit(f,x,y) But the question is now, how does one go about defining the function in point 1. if the function contains an integral (or a discrete sum), e.g.: The experimental data is still given for x and f(x), so point 2. would be similar I imagine once I can define f(x) in python. By the way I forgot to say that it is assumed that g(t) has a well known form

Fitting a better gaussian to data points?

删除回忆录丶 提交于 2019-12-02 13:14:42
问题 I am trying to fit a gaussian to a set of data points that seem to follow a gaussian distribution. I have already checked a lot of possible ways to do that, but I don't really understand most of them. However, I found one solution that seems to work, but the actual fit I get does not look much more like a gaussian than my data points. Here is my code: import numpy as np import matplotlib.pyplot as plt from scipy import asarray as ar, exp, sqrt from scipy.optimize import curve_fit angles = [-8

data fitting an ellipse in 3D space

倾然丶 夕夏残阳落幕 提交于 2019-12-02 05:24:55
Forum I've got a set of data that apparently forms an ellipse in 3D space (not an ellipsoid, but a curve in 3D). Being inspired by following thread http://au.mathworks.com/matlabcentral/newsreader/view_thread/65773 and with the help from someone ,I manage to get the optimization code running and outputs a set of best parameters x (vector). However, when I try to use this x to replicate the ellipse,the outcomes is a strange straight line in the space. I have been stacked on this for days., still don't know what went wrong....pretty much devastated... I hope someone can shed some light on this.

Fitting a better gaussian to data points?

好久不见. 提交于 2019-12-02 04:27:59
I am trying to fit a gaussian to a set of data points that seem to follow a gaussian distribution. I have already checked a lot of possible ways to do that, but I don't really understand most of them. However, I found one solution that seems to work, but the actual fit I get does not look much more like a gaussian than my data points. Here is my code: import numpy as np import matplotlib.pyplot as plt from scipy import asarray as ar, exp, sqrt from scipy.optimize import curve_fit angles = [-8, -6, -4, -2, 0, 2, 4, 6, 8] data = [99, 610, 1271, 1804, 1823, 1346, 635, 125, 24] angles = ar(angles)