Geometric illlustration of the least squares
| > | with(Student[LinearAlgebra]); |
Warning, the name LeastSquares has been rebound
Warning, the protected name `.` has been redefined and unprotected
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
The command LeastSquaresPlot plots the squares whose total area is minimized by the best line.
| > | LeastSquaresPlot(pairs13); |
![[Plot]](images/mm92.least.squares_59.gif)
| > | LeastSquaresPlot(pairs27); |
![[Plot]](images/mm92.least.squares_60.gif)
There are too many points to get a nice picture. Let us reduce the dataset:
| > | pairs5:=pairs27[7..-17]; |
| > | LeastSquaresPlot(pairs5); |
![[Plot]](images/mm92.least.squares_62.gif)
If we set scaling=unconstrained, the squares look like rectangles but otherwise the drawing (MAYBE - remember that my dataset is "randomized") improves:
| > | display(LeastSquaresPlot(pairs5),scaling=unconstrained); |
![[Plot]](images/mm92.least.squares_63.gif)
Another way of improving the drawing MAY BE to limit the view.
| > | display(LeastSquaresPlot(pairs5),view=[0..16, 0..19]); |
![[Plot]](images/mm92.least.squares_64.gif)
| > |