Least Squares Demonstration by George Sturr

Least Squares Demonstration by George Sturr
Loading the math board and drawing, please wait…
2014-05-09 11:22
This example demonstrates the least squares concept. Students can drag a line to find the best fit using squared residuals. Commands used include Point, Circle, Slope, Segment, Polygon, FitLineY, SDX, SDY, Sum, TableText, If, etc. Suitable for middle school and above students to learn statistics and linear regression.

GeoGebra Commands & Parameters

  1. Point(yAxis) → P_1
  2. Circle(P_1, 16) → c
  3. Point(c) → P_2
  4. Slope(Line[P_2, P_1]) → m
  5. Segment(P_6, Q_1) → d
  6. Segment(P_7, Q_2) → e
  7. Segment(P_4, Q_4) → h
  8. Segment(P_5, Q_5) → j
  9. Polygon(P_6, Q_1, 4) → poly2, q, s, t, a_1, E, F
  10. Polygon(P_7, Q_2, 4) → poly3, b_1, c_1, d_1, e_1, G, H
  11. Polygon(P_4, Q_4, 4) → poly4, f_1, g_1, h_1, i_1, I, J
  12. Polygon(P_5, Q_5, 4) → poly6, n_1, p_1, q_1, r_1, M, N
  13. Segment(Q_3, P_3) → g
  14. Polygon(P_3, Q_3, 4) → poly7, r, s_1, t_1, a_2, O, P
  15. FitLineY(pts) → regLine
  16. SDX(pts) → sx
  17. SDY(pts) → sy
  18. Sum(F2:F6) → F7
  19. TableText({B1:B6, C1:C6}, "v|_") → t1
  20. TableText({B1:B6, C1:C6, D1:D6, E1:E6}, "v|_") → t2
  21. TableText({B1:B6, C1:C6, D1:D6, E1:E6, F1:F7}, "v|_") → t3
  22. If(showRes, If[showRes2, t3, t2], t1) → t4
  23. If(showRes2, "total") → E7
  24. If(showRes ∧ showRes2, TableText[{B1:B6, C1:C6, D1:D6, E1:E6, F1:F7}, "v|_"], If[showRes, TableText[{B1:B6, C1:C6, D1:D6, E1:E6}, "v|_"], TableText[{B1:B6, C1:C6, D1:D6}, "v|_"]]) → text3

AI Drawing Prompt Reference

Draw a coordinate system with a line that can be dragged to find the best fit line. By moving point P2 on circle c, adjust the slope m to minimize the vertical distances between line segments d, e, h, j and points P1, Q1, Q2, P2. Draw four quadrilaterals poly2, poly3, poly4, and poly6, and a triangle poly7 to show residuals. Use FitLineY to fit the line regLine, and calculate sx and sy to display the total sum of squared residuals.
The prompt above was compiled from the original drawing commands and is for reference only.