Data fitting is to fit a line through a data set i.e. a series of data points.
Questions tagged [data-fitting]
853 questions
9
votes
1 answer
How to get error estimates for fit parameters in scipy.stats.gamma.fit?
I have some which I am fitting to the gamma distribution using scipy.stats. I am able to extract the shape, loc, and scale params and they look reasonable with the data ranges I expect.
My question is: is there a way to also get the errors in the…

iluvatar
- 872
- 10
- 21
8
votes
1 answer
Fit a distribution to a histogram
I want to know the distribution of my data points, so first I plotted the histogram of my data. My histogram looks like the following:
Second, in order to fit them to a distribution, here's the code I wrote:
size = 20000
x = scipy.arange(size)
#…

aloha
- 4,554
- 6
- 32
- 40
8
votes
1 answer
Fit a 3D line to 3D point data in Java?
I've spent a decent amount of time trying to hunt down a simple way of doing this - ideally, a magical library exists out there somewhere that will take my set of 3D data points and return 2 points on the best fit line using either orthogonal…

zaczap
- 1,386
- 1
- 14
- 20
8
votes
1 answer
Lorentzian scipy.optimize.leastsq fit to data fails
Since I took a lecture on Python I wanted to use it to fit my data. Although I have been trying for a while now, I still have no idea why this is not working.
What I would like to do
Take one data-file after another from a subfolder (here called:…

user2082635
- 81
- 1
- 1
- 3
7
votes
1 answer
Python power law fit with upper limits & asymmetric errors in data using ODR
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…

astrostudent
- 71
- 1
- 3
7
votes
2 answers
Is there a GNU Octave equivalent for the Matlab function "fit"?
My teacher in the signal analysis course has given me some Matlab code that I have to execute in order to complete a home assignment. I have always been using GNU Octave without troubles, but this time there is this command that is giving me…

wizclown
- 313
- 1
- 4
- 16
6
votes
1 answer
Fit a shape to points
I am trying to fit known well-defined shapes (eg boxes, cylinders; with configurable positions, rotations and dimensions) to a set of points with normals generated from sampling a 3D mesh. My current method is to define a custom fit function for…

Epic Wink
- 796
- 13
- 18
6
votes
2 answers
Does name and order of Features matter for prediction algorithm
Do the names/order of the columns of my X_test dataframe have to be the same as the X_train I use for fitting?
Below is an example
I am training my model with:
model.fit(X_train,y)
where X_train=data['var1','var2']
But then during prediction, when…

Tartaglia
- 949
- 14
- 20
6
votes
3 answers
How can I fit two linear functions to a set of data points?
I have a set of data points, which appear sort of like a line with a curve near the beginning. See the image below, which shows the points with a line of best fit (fit to the whole data set).
Instead, they could be described by two linear functions…

curious_cosmo
- 1,184
- 1
- 18
- 36
6
votes
2 answers
Least square method in python?
I have these values:
T_values = (222, 284, 308.5, 333, 358, 411, 477, 518, 880, 1080, 1259) (x values)
C/(3Nk)_values = (0.1282, 0.2308, 0.2650, 0.3120 , 0.3547, 0.4530, 0.5556, 0.6154, 0.8932, 0.9103, 0.9316) (y values)
I know they follow the…

Philipp
- 404
- 1
- 5
- 17
6
votes
2 answers
Getting covariance matrix of fitted parameters from scipy optimize.least_squares method
I am using scipy.optimize's least_squares method in order to perform a constrained non-linear least squares optimization. I was wondering how I would go about getting the covariance matrix of the fitted parameters in order to get error bars on the…

user19346
- 303
- 3
- 9
6
votes
2 answers
gnuplot - Does `set xrange [x_min:x_max]` limit the ranged used for function fit?
Simple question - the range drawn on a plot can be changed with the set xrange [x_min:x_max] command.
Does this command also limit the range used when fitting a function using the data fitting tools in gnuplot? Is there a way to manually specify the…

FreelanceConsultant
- 13,167
- 27
- 115
- 225
6
votes
1 answer
Fitting complex model using Python and lmfit?
I would like to fit ellipsometric data to complex model using LMFit. Two measured parameters, psi and delta, are variables in a complex function rho.
I could try with separating problem to real and imaginary part with shared parameters or piecewise…

Jur Kravla
- 61
- 1
- 3
5
votes
3 answers
find robust fit of a model function in noisy signal
I have a noisy signal and a model function, for example:
x=linspace(0,20);
w=[2 6 -4 5];
y=w(1)*besselj(0,x)+w(2)*besselj(1,x)+w(3)*besselj(2,x)+w(4)*besselj(3,x);
y(randi(length(y),[1 10]))=10*rand(1,10)-5;
plot(x,y,'x')
I thought to use RANSAC…

bla
- 25,846
- 10
- 70
- 101
5
votes
3 answers
How to print Gaussian curve fitting results?
It took me some time but I have used the code below to create myself a Gaussian fit for my x,y data set.
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import curve_fit
def Gauss(x, a, x0, sigma, offset):
return a *…

NapolyoN
- 337
- 3
- 12