Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Curve fitting
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Algebraic fitting of functions to data points{{anchor|Functions|Algebraic}}== Most commonly, one fits a function of the form {{math|''y''{{=}}''f''(''x'')}}. ===Fitting lines and polynomial functions to data points{{anchor|Polynomials}}=== {{main|Polynomial regression}} {{See also|Polynomial interpolation}} [[File:Curve fitting.svg|alt=Polynomial curves fitting a sine function|thumb|upright=1.3|Polynomial curves fitting points generated with a sine function. The black dotted line is the "true" data, the red line is a <span style="color:red">first degree polynomial</span>, the green line is <span style="color:green">second degree</span>, the orange line is <span style="color:orange">third degree</span> and the blue line is <span style="color:blue">fourth degree.</span>]] The first degree [[polynomial]] equation :<math>y = ax + b\;</math> is a line with [[slope]] ''a''. A line will connect any two points, so a first degree polynomial equation is an exact fit through any two points with distinct x coordinates. If the order of the equation is increased to a second degree polynomial, the following results: :<math>y = ax^2 + bx + c\;.</math> This will exactly fit a simple curve to three points. If the order of the equation is increased to a third degree polynomial, the following is obtained: :<math>y = ax^3 + bx^2 + cx + d\;.</math> This will exactly fit four points. A more general statement would be to say it will exactly fit four '''constraints'''. Each constraint can be a point, [[angle]], or [[curvature]] (which is the reciprocal of the radius of an [[osculating circle]]). Angle and curvature constraints are most often added to the ends of a curve, and in such cases are called '''end conditions'''. Identical end conditions are frequently used to ensure a smooth transition between polynomial curves contained within a single [[spline (mathematics)|spline]]. Higher-order constraints, such as "the change in the rate of curvature", could also be added. This, for example, would be useful in highway [[Cloverleaf interchange|cloverleaf]] design to understand the rate of change of the forces applied to a car (see [[Jerk (physics)|jerk]]), as it follows the cloverleaf, and to set reasonable speed limits, accordingly. The first degree polynomial equation could also be an exact fit for a single point and an angle while the third degree polynomial equation could also be an exact fit for two points, an angle constraint, and a curvature constraint. Many other combinations of constraints are possible for these and for higher order polynomial equations. If there are more than ''n'' + 1 constraints (''n'' being the degree of the polynomial), the polynomial curve can still be run through those constraints. An exact fit to all constraints is not certain (but might happen, for example, in the case of a first degree polynomial exactly fitting three [[collinear points]]). In general, however, some method is then needed to evaluate each approximation. The [[least squares]] method is one way to compare the deviations. There are several reasons given to get an approximate fit when it is possible to simply increase the degree of the polynomial equation and get an exact match.: * Even if an exact match exists, it does not necessarily follow that it can be readily discovered. Depending on the algorithm used there may be a divergent case, where the exact fit cannot be calculated, or it might take too much computer time to find the solution. This situation might require an approximate solution. * The effect of averaging out questionable data points in a sample, rather than distorting the curve to fit them exactly, may be desirable. * [[Runge's phenomenon]]: high order polynomials can be highly oscillatory. If a curve runs through two points ''A'' and ''B'', it would be expected that the curve would run somewhat near the midpoint of ''A'' and ''B'', as well. This may not happen with high-order polynomial curves; they may even have values that are very large in positive or negative [[magnitude (mathematics)|magnitude]]. With low-order polynomials, the curve is more likely to fall near the midpoint (it's even guaranteed to exactly run through the midpoint on a first degree polynomial). * Low-order polynomials tend to be smooth and high order polynomial curves tend to be "lumpy". To define this more precisely, the maximum number of [[inflection point]]s possible in a polynomial curve is ''n-2'', where ''n'' is the order of the polynomial equation. An inflection point is a location on the curve where it switches from a positive radius to negative. We can also say this is where it transitions from "holding water" to "shedding water". Note that it is only "possible" that high order polynomials will be lumpy; they could also be smooth, but there is no guarantee of this, unlike with low order polynomial curves. A fifteenth degree polynomial could have, at most, thirteen inflection points, but could also have eleven, or nine or any odd number down to one. (Polynomials with even numbered degree could have any even number of inflection points from ''n'' - 2 down to zero.) The degree of the polynomial curve being higher than needed for an exact fit is undesirable for all the reasons listed previously for high order polynomials, but also leads to a case where there are an infinite number of solutions. For example, a first degree polynomial (a line) constrained by only a single point, instead of the usual two, would give an infinite number of solutions. This brings up the problem of how to compare and choose just one solution, which can be a problem for both software and humans. Because of this, it is usually best to choose as low a degree as possible for an exact match on all constraints, and perhaps an even lower degree, if an approximate fit is acceptable. [[File:Gohana inverted S-curve.png|thumb|upright=1.25|Relation between wheat yield and soil salinity<ref>[https://www.waterlog.info/sigmoid.htm Calculator for sigmoid regression]</ref>]] ===Fitting other functions to data points=== Other types of curves, such as [[trigonometric functions]] (such as sine and cosine), may also be used, in certain cases. In spectroscopy, data may be fitted with [[Normal distribution|Gaussian]], [[Cauchy distribution|Lorentzian]], [[Voigt function|Voigt]] and related functions. In biology, ecology, demography, epidemiology, and many other disciplines, the [[Population growth|growth of a population]], the spread of infectious disease, etc. can be fitted using the [[logistic function]]. In [[agriculture]] the inverted logistic [[sigmoid function]] (S-curve) is used to describe the relation between crop yield and growth factors. The blue figure was made by a sigmoid regression of data measured in farm lands. It can be seen that initially, i.e. at low soil salinity, the crop yield reduces slowly at increasing soil salinity, while thereafter the decrease progresses faster.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)