Questions tagged [function-fitting]

62 questions
1
vote
0 answers

how to choose the best fitting function for a data set

I am trying to find the best fitting function for some data. I have tried with : my_model = np.poly1d(np.polyfit(arr_x, arr_y, 4)) plt.plot(arr_x, my_model(arr_x), 'g-') where arr_x and arr_y are original data. This is what comes out: The…
1
vote
1 answer

fitting a model to a density distribution in R

I am trying to figure out how to fit a published model to a dataset. Details of the model and equation are shown here 1 I have a dataframe of apparent diffusion (D*) from the equation in 1 and also the number of steps (n). I need to fit my data…
1
vote
1 answer

Trying to fit a line of constant slope to two specific ranges of data points

I am working with 10,000 data points from a .csv file and need to fit constant functions to two specific ranges (of time here) so that I can average their y-intercepts and subtract that from the y-values of the data (voltage in this case). My fits,…
1
vote
2 answers

Fitting with constraints on derivative Python

While trying to create an optimization algorithm, I had to put constraints on the curve fitting of my set. Here is my problem, I have an array : Z = [10.3, 10, 10.2, ...] L = [0, 20, 40, ...] I need to find a function that fits Z with condition on…
1
vote
1 answer

How to get errors of parameters from maximum likelihood estimation with known likelihood function in python?

I have a some data and want to fit a given psychometric function p. I'm intereseted in the fit parameters and the errors as well. With the 'classical' method using the curve_fit function from the scipy package it's easy to get the parameters of p…
Lukas
  • 73
  • 1
  • 10
1
vote
3 answers

Exponential decay fit in r

I would like to fit an exponential decay function in R to the following data: data <- structure(list(x = 0:38, y = c(0.991744340878828, 0.512512332368168, 0.41102449265681, 0.356621905557202, 0.320851602373477, 0.29499198506227, 0.275037747162642,…
Scratch
  • 57
  • 1
  • 1
  • 6
1
vote
1 answer

MATLAB fitting matrices

I got the case P(t) = a * A(t) - b* B(t), each 17281x1 doubles. Now I want to use curve fitting to get the variables a and b. Fitting case, here a and b as 1 and 1 I know fit and fittype, but they seem not to work in this case. Any ideas, how to…
Kilian Weber
  • 160
  • 1
  • 8
1
vote
2 answers

leastsq trouble passing parameters Python

I am trying to fit the following function: Detrended SNR into my data. C1, C2 and h are the parameters I need to obtain from the leastsq's method. C1 and C2 are simple but the problem is that my h(t) is in reality: . What I want to obtain are the…
1
vote
1 answer

Is it necessary to define the backward function for the frozen layers?

I have a function fitting network with 4 hidden layers. I need to find suitable weights for the first and the third layers, while the second and the fourth layers are some kinds of normalization layers and do not need to be learned, so I just froze…
1
vote
2 answers

Opencv - polynomial function fitting

In opencv (or other c++ lib), is there a similar function like matlab fit which can do 3d polynomial surface fitting (i.e. f(x,y)= p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2). Thanks
fnhdx
  • 321
  • 2
  • 5
  • 14
1
vote
0 answers

gnuplot - Function fit fails due to complex number (undefined value)

I am using gnuplot to fit some data, however I notice that sometimes my function fails to fit. I believe this is due to an undefined value which arises due to taking the square root of a negative number. (My understanding is gnuplot fit cannot cope…
FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225
1
vote
1 answer

Resistivity non linear fit in Python

I'm trying to fit Einstein approximation of resistivity in a solid in a set of experimental data. I have resistivity vs temperature (from 200 to 4 K) import xlrd as xd import matplotlib.pyplot as plt import numpy as np import pylab as pl import…
iacolippo
  • 4,133
  • 25
  • 37
0
votes
1 answer

How to fit a a*cos(x)**b function to data in gnuplot? (Malus' Law)

I'm trying to verify Malus' Law I = I_0 * cos^2(x) by fitting a function to data obtained during an experiment. The method I've been using does give me a realistic value for I_0, but not for the exponent. The function it gives me, does not look like…
0
votes
0 answers

How to make scipy.optimize.differential_evolution ignore 'nan' evaluations?

I am trying to optimize a complex PDE using differential_evolution. Sometimes my function for specific cases returns 'nan' and the differential evolution evaluation report takes that as the result of the evaluation. How can I tell the optimizer to…
0
votes
1 answer

Adding constraints to my fitting model using lmfit

I am trying to fit a complex conductivity model (the drude-smith-anderson model) using lmfit.minimize. In that fitting, I want constraints on my parameters c and c1 such that 0