Difference between revisions of "Fit Command"

From GeoGebra Manual
Jump to: navigation, search
(* If you work with big/small numbers, you should consider normalizing them for a more accurate result, see Normalize Command.)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|statistics}}
 
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|statistics}}
;Fit[ &lt;List of Points>, &lt;List of Functions> ]
+
;Fit( &lt;List of Points>, &lt;List of Functions> )
 
:Calculates a linear combination of the ''functions'' that best fit the ''points'' in the list.
 
:Calculates a linear combination of the ''functions'' that best fit the ''points'' in the list.
 
:{{example|1=<div>
 
:{{example|1=<div>
:* <code>Fit[{(-2, 3), (0, 1), (2, 1), (2, 3)}, {x^2, x}]</code> yields ''0.625 x^2 - 0.25x''.
+
:* <code>Fit({(-2, 3), (0, 1), (2, 1), (2, 3)}, {x^2, x})</code> yields ''0.625 x^2 - 0.25x''.
:* Let  ''L = {A, B, C, ...}'', ''f(x) = 1'', ''g(x) = x'', ''h(x) = e^x'', ''F = {f, g, h}''.<br> <code>Fit[L, F]</code> calculates a function of the form ''a + b x + c e^x'' that fits the points in the list. </div>}}
+
:* Let  ''L = {A, B, C, ...}'', ''f(x) = 1'', ''g(x) = x'', ''h(x) = e^x'', ''F = {f, g, h}''.<br> <code>Fit(L, F)</code> calculates a function of the form ''a + b x + c e^x'' that fits the points in the list. </div>}}
;Fit[ &lt;List of points>, <Function> ]
+
;Fit( &lt;List of points>, <Function> )
 
:Calculates a minimum squared error function  to the points in the list. The ''function'' must depend on one or more sliders, that are taken as start values of parameters to be optimized. The non-linear iteration might not converge, but adjusting the sliders to a better starting point might help.
 
:Calculates a minimum squared error function  to the points in the list. The ''function'' must depend on one or more sliders, that are taken as start values of parameters to be optimized. The non-linear iteration might not converge, but adjusting the sliders to a better starting point might help.
:{{example|1=<div>Let ''a'' be slider with interval from ''-5'' to ''5'' and increment 1. <br> <code><nowiki>Fit[{(-2, 3), (0, 1), (2, 1), (2, 3)}, a + x^2]</nowiki></code> yields ''-1 + x^2''.</div>}}
+
:{{example|1=Let ''a'' be slider with interval from ''-5'' to ''5'' and increment 1. <code><nowiki>Fit({(-2, 3), (0, 1), (2, 1), (2, 3)}, a + x^2)</nowiki></code> yields ''-1 + x^2''.}}
{{note|1=Other point fitting commands are [[FitExp Command|FitExp]], [[FitGrowth Command|FitGrowth]], [[FitLine Command|FitLine]], [[FitLineX Command|FitLineX]], [[FitLog Command|FitLog]], [[FitLogistic Command|FitLogistic]], [[FitPoly Command|FitPoly]], [[FitPow Command|FitPow]] and [[FitSin Command|FitSin]].}}
+
 
 +
{{note| 1=<div>
 +
*See also [[FitExp Command|FitExp]], [[FitGrowth Command|FitGrowth]], [[FitLine Command|FitLine]], [[FitLineX Command|FitLineX]], [[FitLog Command|FitLog]], [[FitLogistic Command|FitLogistic]], [[FitPoly Command|FitPoly]], [[FitPow Command|FitPow]] and [[FitSin Command|FitSin]]
 +
* If you work with big/small numbers, you should consider normalizing them for a more accurate result, see  [[Normalize Command]].
 +
</div>}}

Latest revision as of 12:45, 4 February 2019


Fit( <List of Points>, <List of Functions> )
Calculates a linear combination of the functions that best fit the points in the list.
Example:
  • Fit({(-2, 3), (0, 1), (2, 1), (2, 3)}, {x^2, x}) yields 0.625 x^2 - 0.25x.
  • Let L = {A, B, C, ...}, f(x) = 1, g(x) = x, h(x) = e^x, F = {f, g, h}.
    Fit(L, F) calculates a function of the form a + b x + c e^x that fits the points in the list.
Fit( <List of points>, <Function> )
Calculates a minimum squared error function to the points in the list. The function must depend on one or more sliders, that are taken as start values of parameters to be optimized. The non-linear iteration might not converge, but adjusting the sliders to a better starting point might help.
Example: Let a be slider with interval from -5 to 5 and increment 1. Fit({(-2, 3), (0, 1), (2, 1), (2, 3)}, a + x^2) yields -1 + x^2.


Note:
© 2024 International GeoGebra Institute