Bivariate Statistics: Fast Correlation and Regression Computations

Bivariate Statistics: Fast Correlation and Regression Computations
Loading the math board and drawing, please wait…
2024-04-25 03:24
This GeoGebra example demonstrates how to quickly compute and display key results for two statistical variables within a single interactive workflow. It covers the full pipeline from data handling to covariance and correlation (via PMCC), supporting linear correlation/regression analysis. The main concepts include descriptive statistics in two variables—mean, variance, population/sample standard deviation—as well as covariance and the Pearson correlation coefficient used in regression-related inference. Construction-wise, it uses commands such as Unique, Sequence, Transpose, Length, and Append to generate and organize data; TableText and Textfield to present results and accept inputs; Sum, mean, Variance, stdevp, stdev, and Covariance to compute statistical measures; and PMCC to calculate the correlation metric. Objects like the input field (CasillaDeEntrada1), multiple text outputs (texto1–texto6), and parameter/data holders (e.g., mx, my, varx, desvx) are organized to create an input→compute→visualize statistical panel. Suitable for secondary school and early university probability & statistics classes, regression/correlation practice, and classroom demonstrations of how correlation changes with the underlying data.

GeoGebra Commands & Parameters

  1. Unique(Sequence[(l1(i) * (1, 0)), i, 1, Length[l1]]) → l2
  2. Unique(Sequence[(l1(i) * (0, 1)), i, 1, Length[l1]]) → l3
  3. Sequence(Sequence[Sequence[(l2(i), l3(j)) ≟ l1(k), k, 1, Length[l1]], j, 1, Length[l3]], i, 1, Length[l2]) → l4, {{{true, false, false, false, false, false, false, true, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}}, {{false, false, false, false, false, false, false, false, true}, {false, true, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}}, {{false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, true, false, false, false, false, false, false}, {false, false, false, true, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}}, {{false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, false, false, false, false, false}, {false, false, false, false, true, true, false, false, false}, {false, false, false, false, false, false, true, false, false}}}
  4. Sequence(Sequence[Sum[l4(i, j)], j, 1, Length[l3]], i, 1, Length[l2]) → m, {{2, 0, 0, 0, 0}, {1, 1, 0, 0, 0}, {0, 0, 1, 1, 0}, {0, 0, 0, 2, 1}}
  5. Transpose(m) → m1
  6. Length(l2) → n
  7. Append("", l2) → l5
  8. Sequence(Sum[m1(i)], i, 1, Length[l3]) → l8
  9. Append(Append[l3(1), Sequence[m1(1, j), j, 1, n]], l8(1)) → f1
  10. Append(Append[l3(2), Sequence[m1(2, j), j, 1, n]], l8(2)) → f2
  11. Append(Append[l3(3), Sequence[m1(3, j), j, 1, n]], l8(3)) → f3
  12. Append(Append[l3(4), Sequence[m1(4, j), j, 1, n]], l8(4)) → f4
  13. Append(Append[l3(5), Sequence[m1(5, j), j, 1, n]], l8(5)) → f5
  14. Append("", Sequence[Sum[m(i)], i, 1, Length[l2]]) → l6
  15. Textfield(l1) → CasillaDeEntrada1
  16. Sequence(Append[Append[l3(i), Sequence[m1(i, j), j, 1, n]], l8(i)], i, 1, Length[l3]) → m2
  17. Transpose(m2) → m3
  18. Sequence(Append[Append[l5(i), Sequence[m3(i, j), j, 1, Length[l3]]], l6(i)], i, 1, Length[l2] + 2) → m4
  19. TableText(Transpose[m4], "c_|v") → texto1
  20. Sum(Sequence[Sum[m(i)], i, 1, Length[l2]]) → a
  21. Sequence(Sum[m(i)], i, 1, Length[l2]) → l9
  22. Sequence((l9(i) * l2(i)), i, 1, Length[l2]) → l10, {3, 3.1, 3.2, 5.1}
  23. Sum(l10) → b
  24. Sequence(((l9(i) * l2(i)) * l2(i)), i, 1, Length[l2]) → l11, {4.5, 4.805000000000001, 5.120000000000001, 8.67}
  25. Sum(l11) → c
  26. TableText(Append[Append["X_i", l2], "N"], Append[Append["f_i", Sequence[Sum[m(i)], i, 1, Length[l2]]], a], Append[Append["x_i·f_i", l10], b], Append[Append["x_i^2·f_i", l11], c], "v_|c") → texto4
  27. Sequence((l3(j) * l8(j)), j, 1, Length[l3]) → l12, {162, 56, 60, 195, 68}
  28. Sum(l12) → d
  29. Sequence(((l3(j) * l8(j)) * l8(j)), j, 1, Length[l3]) → l13, {486, 56, 60, 585, 68}
  30. Sum(l13) → e
  31. TableText(Append[Append["Y_j", l3], "N"], Append[Append["f_j", Sequence[Sum[m1(i)], i, 1, Length[l3]]], Sum[l8]], Append[Append["y_j·f_j", l12], d], Append[Append["y_j^2·f_j", l13], e], "v_|c") → texto6
  32. mean(l2, l9) → mx
  33. Variance(l2, l9) → varx
  34. stdevp(l2, l9) → desvx
  35. mean(l3, l8) → my
  36. Variance(l3, l8) → vary
  37. stdev(l3, l8) → desvy
  38. Covariance(l1) → cov
  39. PMCC(l1) → cregre
  40. Sequence("f" + (i) + "=Append(Append(l3(" + (i) + "),Sequence(m1(" + (i) + ",j),j,1,n)),l8(" + (i) + "))", i, 1, Length[l2] + 1) → l7

AI Drawing Prompt Reference

Please draw a bivariate statistics calculation panel. The panel includes an input box for data entry, two tables showing statistics for X and Y, and multiple text labels displaying statistical measures. The input box is connected to the calculation process, and results are filled into tables and text. The construction order is: first create the input box, generate data sequences, compute mean, variance, standard deviation, covariance, and correlation coefficient, and finally display results in tables and text.
The prompt above was compiled from the original drawing commands and is for reference only.