Fitting polynomials to data

前端 未结 10 2160
生来不讨喜
生来不讨喜 2020-11-28 01:39

Is there a way, given a set of values (x,f(x)), to find the polynomial of a given degree that best fits the data?

I know polynomial interpolation, whic

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 02:20

    If you want to fit the (xi, f(xi)) to an polynomial of degree n then you would set up a linear least squares problem with the data (1, xi, xi, xi^2, ..., xi^n, f(xi) ). This will return a set of coefficients (c0, c1, ..., cn) so that the best fitting polynomial is *y = c0 + c1 * x + c2 * x^2 + ... + cn * x^n.*

    You can generalize this two more than one dependent variable by including powers of y and combinations of x and y in the problem.

提交回复
热议问题