Approximating/Fitting a function to points

  • Thread starter Thread starter thomas49th
  • Start date Start date
  • Tags Tags
    Function Points
Click For Summary
SUMMARY

This discussion focuses on methods for fitting a function to a set of discrete points, specifically using polynomial fitting techniques. The provided points (1,4), (2,5), (3,2), (4,7), (5,1), and (6,1) can be approximated using a polynomial of the form y = a + bx + cx² + dx³ + ex⁴ + fx⁵, resulting in a system of equations to solve for the coefficients. It is emphasized that higher-order polynomials can lead to overfitting and that piecewise fits are often preferred for interpolation. Additionally, optimization criteria such as minimum mean squared error should be considered when fitting functions to data.

PREREQUISITES
  • Understanding of polynomial fitting techniques
  • Familiarity with optimization criteria like minimum mean squared error
  • Knowledge of interpolation methods, particularly piecewise fits
  • Basic grasp of function approximation concepts, including Taylor series
NEXT STEPS
  • Research polynomial regression techniques in Python using libraries like NumPy and SciPy
  • Explore piecewise function fitting methods and their applications
  • Learn about optimization algorithms for minimizing error in data fitting
  • Investigate alternative function types for fitting, such as exponential and logarithmic functions
USEFUL FOR

Data scientists, statisticians, and engineers involved in data analysis and modeling who need to fit functions to discrete datasets.

thomas49th
Messages
645
Reaction score
0
Hi, given a function of x, where x increases in uniform increments (ie x goes 1, 2, 3) and y culmalatively increases in the domain x>0, what methods are there to fit a function it to? I want to know method/algorithm that can fit a line/curve to it. So given these points

(1,4)
(2,5)
(3,2)
(4,7)
(5,1)
(6,1)

I want a Cartesian equation (y= function of x) that can accurately plot a curve through these points - like how a taylor series can be used to approximate functions, but I want to be able to produce a function, or approximate one without. I know that the more disperse the points are from each other the higher the degree of the polynomial (if a polynomial method is used)

Thanks
Thomas
 
Physics news on Phys.org
thomas49th said:
Hi, given a function of x, where x increases in uniform increments (ie x goes 1, 2, 3) and y culmalatively increases in the domain x>0, what methods are there to fit a function it to? I want to know method/algorithm that can fit a line/curve to it. So given these points

(1,4)
(2,5)
(3,2)
(4,7)
(5,1)
(6,1)

I want a Cartesian equation (y= function of x) that can accurately plot a curve through these points -
There are infinite possibilities.

like how a taylor series can be used to approximate functions, but I want to be able to produce a function,
You can not determine a unique taylor series unless you have infinite days (i.e. know every derivative. However, you can do a polynormial fit for the form:

y=a+bx+cx^2+ex^3+fx^4+gx^5

For each point, you plug in a value for y and x and you end up with six equations and six unknowns. This is a type of bilinear fit and more generally:

y=a_1f_1(x)+...+a_nf_n(x)

where the functions f_1(z)..f(n) are independent over the points (x_1,y_1),...,(x_n,y_n).

It is generally not a good idea to fit a lot of points with a higher order polynomial because the fit can be real wavy (noisy). For interpolation, piece wise fits are preferred. Also if you are trying to discover any relationship between the points, it is better to have more data, then unknowns. You won't fit the points exactly but if the data was given at random there would be less variance in your estimates. When you are trying to fit more data then you have unknowns you decide on some optimization criteria like minimum mean squared error.
 
Generally speaking, you try to guess the behavior of the trend from the source. Common choices include exponentials, logarithms, polynomials, and rationals. Trig functions, too. Just play around. Unless you have some clue as to what the function should look like, you can come up with functions that hit all of those points, that hit some of them, and that are pretty close, ad infinitum.
 

Similar threads

Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
2
Views
2K
Replies
22
Views
3K
  • · Replies 15 ·
Replies
15
Views
2K
Replies
11
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 1 ·
Replies
1
Views
688