WLJS LogoWLJS Notebook

Fit

Fit[data, {f1, f2, ...}, x] finds a least-squares fit of the form a1f1+a2f2+...a_1 f_1 + a_2 f_2 + ... to the data.

Examples

Fit data to polynomial models:

data = {{1, 1.2}, {2, 3.9}, {3, 9.1}, {4, 15.8}}

(* Linear fit *)
Fit[data, {1, x}, x]
(* -2.25 + 4.63 x *)

(* Quadratic fit *)
Fit[data, {1, x, x^2}, x]
(* 0.05 + 0.02 x + 1.0 x^2 *)

Please visit the official Wolfram Language Reference for more details.

On this page