How do I best fit a function's parameters to a curve

In summary, the individual is seeking help with using the Havriliak-Negami equation and a data set to find the optimal values for the function's parameters C1 to C4 in order to best fit the data set. They are considering using a separate curve fitting method followed by comparing Fourier series, but are looking for a potential Matlab function that could simplify this process.
  • #1
rsr_life
51
0
Hello,

Suppose,
1. I have a function f=C1 + C2/((C3-X)^C4); where Cn is a constant;
I'm looking at the Havriliak-Negami equation which has some 5 constants.

2. I have a data set whose least-squares fit looks like a curve,

How can I compute the values of the function's parameters C1 to C4 that would best fit this function 1 to the curve?

One idea I had was to do a separate curve fitting for the data set (using a polynomial or a set of gaussians), then take the Fourier series of that resulting fitting function; compare those terms to the Fourier series of this function f, and solve any resulting equations containing C1 to C4.

But I bet there's some Matlab function that does this job better if I simply supply the data set and the function? i.e. it optimizes the functions parameters to get me the best least squares fit to the data set?

Any help with Matlab or pointers to this is appreciated!

Many thanks.
 
Engineering news on Phys.org
  • #3
Ok. A fit of the function I described to any curve that would best cover the data set I have.

The data set, when plotted, looks like a half ellipse (and is independent of the function).

I need to find the values of the the function's parameters C1 to C4 that would best fit this curve. There are other functions too that could describe this dataset, but I need to compute how I could specifically use this function to describe them.

Thank you!
 
  • #4
Those links I gave you should help with what you want.
 
  • #5


Hello,

Thank you for your question. Fitting a function's parameters to a curve is a common task in scientific research and can be approached in several ways. One approach is to use a least-squares fitting method, which minimizes the sum of the squared differences between the data points and the curve. This can be done using various software packages, including Matlab, by providing the data set and the function to be fitted.

In your case, where you have a function with 5 constants, you can use Matlab's "lsqcurvefit" function. This function allows you to specify a function, initial parameter values, and a data set, and it will return the optimized parameter values that best fit the data to the given function. You can also specify bounds for the parameters to ensure that they fall within a certain range.

Alternatively, as you mentioned, you can also use a polynomial or Gaussian curve fitting method to fit the data, and then use the resulting coefficients as initial values for the constants in your function. This approach may work well if the data can be approximated well by a polynomial or Gaussian function.

In any case, it is important to keep in mind that the accuracy of the fit will depend on the quality and quantity of the data points, as well as the complexity of the function being fitted. It may be helpful to plot the fitted curve alongside the original data to visually assess the fit and make any necessary adjustments.

I hope this helps. Best of luck with your research!
 

1. How do I determine the appropriate function for my curve?

The best way to determine the appropriate function for your curve is to plot the data and visually inspect the shape. This can give you an idea of what type of function may fit the data well. Additionally, you can try fitting different types of functions (such as linear, polynomial, exponential, etc.) and compare their goodness of fit values to determine the best one.

2. What is the best method for fitting a function's parameters to a curve?

The best method for fitting a function's parameters to a curve depends on the type of function and the data being used. Some common methods include least squares regression, maximum likelihood estimation, and nonlinear optimization. It is important to choose a method that is appropriate for your data and that takes into account any assumptions about the function or data.

3. How many parameters should I use for my function?

The number of parameters to use for a function depends on the complexity of the curve and the amount of data available. Generally, it is best to start with fewer parameters and add more as needed to improve the fit. Too many parameters can lead to overfitting and a poor fit to the data.

4. How do I know if my function is a good fit for my data?

There are several metrics that can be used to determine the goodness of fit for a function to a curve. These include the coefficient of determination (R-squared), the root mean squared error (RMSE), and the Akaike information criterion (AIC). These values can be compared for different functions to determine which one provides the best fit to the data.

5. Can I use software to fit a function's parameters to a curve?

Yes, there are many software programs and libraries available that can help with fitting a function's parameters to a curve. Some popular options include MATLAB, Python's SciPy library, and Microsoft Excel. These programs often have built-in functions for fitting different types of functions to data and can provide useful visualizations and statistics to evaluate the fit.

Similar threads

  • Calculus and Beyond Homework Help
Replies
6
Views
641
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • General Math
Replies
6
Views
782
  • General Math
Replies
2
Views
719
  • Set Theory, Logic, Probability, Statistics
Replies
16
Views
2K
Replies
2
Views
8K
  • Set Theory, Logic, Probability, Statistics
Replies
12
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
28
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
8
Views
894
Back
Top