plot 2-D or 3-D points and a least squares fit to those points
LeastSquaresPlot(L, var, opts)
LeastSquaresPlot(Lx, Ly, var, opts)
LeastSquaresPlot(Lx, Ly, Lz, var, opts)
list of lists of pairs or list of triples of algebraic values
Lx, Ly, Lz
lists of algebraic values
(optional) name or list of 1 name (2-D case); list of 2 names (3-D case)
plotting options or equation(s) of the form option=value where option is one of showboxes, boxoptions, showcurve or showsurface, curveoptions or surfaceoptions, showpoints, pointoptions, curve or surface, or Student plot options; specify options for the plot
The LeastSquaresPlot(L) command plots the points specified by L, the least squares fit curve or surface, and the errors associated with this fit. Errors are represented as squares (2-D) or rectangular solids (3-D). The area or volume of these boxes is equal to the square of the error between the approximating curve or surface and the data point to which the box is attached.
The points can be given as either a list of lists of 2- or 3-element points, or as two lists representing the components of 2-D points, or three lists representing the components of 3-D points.
Note: This command takes a slightly different approach to solving the least squares problem than does the LeastSquares command. The latter command solves a linear system, as represented by a Matrix and a right-hand side Vector, in the least squares sense. The relation between the two approaches is that the Matrix and Vector arguments to the LeastSquares command are obtained by evaluating the model curve or surface (as specified by the curve or surface argument) at each of the points given in the list argument(s) to this command.
The names of the independent variables can be given as an optional argument var. Otherwise the variables x, or x and y are used. If the curve or surface option is given, the variable name(s) must also be explicitly given.
The opts argument can contain any of the Student plot options or any of the following equations that set plot options.
showboxes = true or false
Select whether the boxes representing the errors are plotted. [Default: true]
boxoptions = list
A list of options for the plot of the boxes representing the errors. For more information on plot options, see plot/options. [Default: solid blue squares or rectangular solids]
showcurve = true or false or showsurface = true or false
Select whether the fitting curve or surface is plotted. [Default: true]
curveoptions = list or surfaceoptions = list
A list of options for the plot of the fitting curve or surface. For more information on plot options, see plot/options. [Default: red curve (2-D), red wire frame (3-D)]
showpoints = true or false
Select whether the points being fitted are plotted. [Default: true]
pointoptions = list
A list of options for plotting the points being fitted. For more information on plot options, see plot/options. [Default: black circles]
curve = algebraic or surface = algebraic
An expression in the variables that specifies the curve or surface to which to fit the data. This curve or surface must be linear in the unknown parameter(s), and the variable names must be given in the var parameter. For example, the curve a*x^2+b*x*y+c is acceptable because it is linear in the parameters a, b, and c. [Default: a⁢x+b (2-D), a⁢x+b⁢y+c (3-D)]
caption = anything
A caption for the plot.
The default caption is constructed from the parameters and the command options. caption = "" disables the default caption. For more information about specifying a caption, see plot/typesetting.
These are the commands to create the plots in the Plotting Guide.
Fitting curve: -.3148+.7556*x
Least squares error: .4979
Maximum error: .3708
Compare the use of the LeastSquaresPlot command with that of the LeastSquares command, which solves a linear system in the least-squares sense.
A≔10.99749498660.36145004350.362357754510.9092974268−0.02655105049−0.0291995223010.5984721441−0.2490522895−0.416146836510.1411200081−0.1040610071−0.73739371551−0.35078322770.3305157939−0.94222234071−0.75680249530.7555119774−0.99829477581−0.97753011770.8766083602−0.89675841631−0.95892427470.6267947351−0.65364362091−0.70554032560.2168357332−0.30733287001−0.2794154982−0.024448572050.08749898344⋮⋮⋮⋮13 × 4 Matrix
B≔0.48692381540.33773159030.07056000403−0.2212602217−0.4357878862−0.4980823044−0.3863822437−0.13970774910.15577068170.3968339319⋮13 element Vector[column]
Fitting surface: .3113-.1089*x+.5662*y-.4173*x*y
Least squares error: .3848
Maximum error: .2300
Student plot options
Download Help Document
What kind of issue would you like to report? (Optional)