Questions tagged [function-fitting]

62 questions
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
5
votes
1 answer

gnuplot - get errors on fit parameters, get fit output values as variables, print variable to screen

Initial Question (Partially Answered) I am using gnuplot's fitting routines to fit a function to some data, and extract a "characteristic decay time constant". (I call this parameter d in my fitting function.) I have used the script code set fit…
4
votes
1 answer

Curve fitting with python error

I'm trying to fit my data to (cos(x))^n. The vale of n in theory is 2, but my data should give me around 1.7. When I define my fitting function and I try curve_fit, I get an error def f(x,a,b,c): return a+b*np.power(np.cos(x),c) param, extras =…
3
votes
2 answers

Unable to fit data due to "can't multiply sequence by non-int of type 'numpy.float64'" error

I'm trying to fit and plot a simple data in a .txt file with a linear function (a*x+b) using matplotlib and scipy. I run into an error concerning the test function: "can't multiply sequence by non-int of type 'numpy.float64'" I have tried changing…
3
votes
1 answer

gnuplot - How can I count the number of entries in a csv file column?

I have a gnuplot code which includes a function fitting routine. This routine is slow when a large number of data points must be fitted. The number of data points in my input file is variable depending on the parameters of some simulations I am…
FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225
3
votes
1 answer

Fitting function through intervals

I have finite series of intervals of real numbers, Ri = (Rimin, Rimax) and series of real numbers ti, i=1..N. My goal is to find a function f:R->R, where for each i is f(ti) in interval Ri. In following image on X axis are ti values under each red…
Matej
  • 86
  • 3
2
votes
1 answer

Python surface fitting of variables of different dimensionto get unknown parameters?

I have a function that includes x and y as independent variables and I want to fit the parameters to the data and function and plot a surface figure. I saw that if the variables have two different dimensions, I can use np.meshgrid(x,y), but then how…
mj1496
  • 61
  • 1
  • 9
2
votes
1 answer

Using scipy.optimize.curve_fit to fit a piecewise function

I am attempting to write a program that reads two sets data from a .csv file into arrays, and then fits it to a piecewise function. What's most important to me is that these fits are done simultaneously because they have the same parameters. This…
2
votes
1 answer

why curve_fit does not converge for a beta function fit?

I have a small problem with my Python code when I try to fit a beta function to a few points. The problem is that either the solution does not converge (and the result coefficients are nans), or it does nothing (at the results stay the same as my…
2
votes
1 answer

Fitting an N-dimensional parabola in python

I have a set of N samples (N~10000 to 100000) : (y_i, P_i) They sample an unknown function : y = f(P) In my case, P is a set of n_p parameters with n_p typically around 10. My aim is to use the samples to find the polynomial of order 2 which…
1
vote
0 answers

How do I fit the Weibull distribution to my dataset?

I'm looking to fit a vector of Floats to the Weibull distribution using the fit() function from Distributions.jl . The error I get is: ERROR: DomainError with NaN: Weibull: the condition α > zero(α) is not satisfied. I've been able to do it for…
1
vote
1 answer

Optimizing a funcation using Scipy to estimate fitting parameters

I am trying to optimize a function by finding its minimum value using Scipy. The code must find the values of the variables g and tau that will give the minimum value of MSE. However, These values must be arrays not scalars. Below is the code import…
1
vote
1 answer

Fit a smoothed/cumulative distribution function to data and predict x from given y

I need to fit a smoothed/cumulative distribution function to my data and afterwards be able to predict the x-value by a given y, this is what my code looks like atm but it doesn´t work as expected, because loess probably isn´t the right method (even…
1
vote
0 answers

Gaussian fit for Python with two different function

I used the Gaussian fit with 3 gauss to adjust but datai but I utility data that sometimes my curve contains only two Gaussians in it not find the parameter remnants to use and but great an error is what there is a method that but allows to change…
1
vote
1 answer

What is causing "TypeError: only size-1 arrays can be converted to Python scalars least_squares" from implementation of scipy.optimize.least_squares

I am attempting to fit a normal distribution to histogram values from seaborn. I am using the following code: from scipy.optimize import least_squares from math import exp def model_normal_dist(x, u): return x[0]*exp(-((x[1]-u)/x[2])**2) def…
DrRaspberry
  • 367
  • 2
  • 13
1
2 3 4 5