QQ Plots

QQ Plots
Loading the math board and drawing, please wait…
2015-08-09 11:46
This example demonstrates QQ plots, a graphical method for comparing the distributions of two data sets. Key mathematical concepts include normal, gamma, and exponential distributions in probability and statistics. Using GeoGebra commands such as RandomUniform, Sort, and Mirror, QQ plots are constructed to visually compare different data distributions. Suitable for high school students and statistics enthusiasts.

GeoGebra Commands & Parameters

  1. SelectedIndex(distributionsmodel) → SelectedModel
  2. SelectedIndex(distributionsreal) → SelectedReal
  3. RandomUniform(0, 1, n) → samplereal
  4. Zip((-9, InverseNormal[μ, σ, yy]), yy, samplereal) → pointsrealNormal
  5. Zip((-9, InverseGamma[3, β, yy] - 2), yy, samplereal) → pointsrealGamma
  6. Zip((-9, InverseExponential[λ, yy] - 2), yy, samplereal) → pointsrealExp
  7. Zip((-9, InverseGamma[s / 2, 2, yy]), yy, samplereal) → pointsreal2
  8. Zip((-9, ((-yy) + s) / sqrt((2 * s)) + 2.5), yy, y(pointsreal2)) → pointsrealSkewLeft
  9. Zip((-9, (yy - s) / sqrt((2 * s))), yy, y(pointsreal2)) → pointsrealSkewRight
  10. If(SelectedReal ≟ 1, pointsrealNormal, If[SelectedReal ≟ 2, pointsrealExp, If[SelectedReal ≟ 3, pointsrealGamma, If[SelectedReal ≟ 4, pointsrealSkewRight, pointsrealSkewLeft]]]) → pointsReal
  11. Sort(y(pointsReal)) → ysortReal
  12. Sequence(k / (n + 1), k, 1, n, 1) → points
  13. Zip((InverseNormal[μ_M, σ_M, yy] - 3, 2.2), yy, points) → pointsmodelNorm
  14. Zip((InverseGamma[3, β_M, yy] - 7, 2.2), yy, points) → pointsmodelGamma
  15. Zip((InverseExponential[λ_M, yy] - 7, 2.2), yy, points) → pointsmodelExp
  16. Zip((InverseGamma[s_M / 2, 2, yy], 2.2), yy, points) → pointsmodel2
  17. Zip(((yy - s_M) / sqrt((2 * s_M)) - 3, 2.2), yy, x(pointsmodel2)) → pointsmodelSkewRight
  18. Mirror(pointsmodelSkewRight, x = -3) → pointsmodelSkewLeft
  19. If(SelectedModel ≟ 1, pointsmodelNorm, If[SelectedModel ≟ 2, pointsmodelExp, If[SelectedModel ≟ 3, pointsmodelGamma, If[SelectedModel ≟ 4, pointsmodelSkewRight, pointsmodelSkewLeft]]]) → pointsModel
  20. Sort(x(pointsModel)) → xsortModel
  21. If(SelectedReal ≟ 1, pointsrealNormal, If[SelectedReal ≟ 2, pointsrealExp, If[SelectedReal ≟ 3, pointsrealGamma, If[SelectedReal ≟ 4, pointsrealSkewRight, pointsrealSkewLeft]]]) → points1
  22. Sort(y(points1)) → points3
  23. Zip((InverseExponential[λ_M, yy] - 7, xx), yy, points, xx, points3) → Fexp
  24. Zip((InverseGamma[3, β_M, yy] - 7, xx), yy, points, xx, points3) → Fgamma
  25. Zip((x(xx), yy), xx, pointsModel, yy, points3) → FSkewRight
  26. Zip((x(xx), yy), xx, pointsModel, yy, points3) → FSkewLeftaux
  27. Zip((xx, yy), xx, xsortModel, yy, ysortReal) → FSkewLeft
  28. Zip((InverseNormal[μ_M, σ_M, yy] - 3, xx), yy, points, xx, points3) → Fnorm
  29. Gamma(s_M / 2, 2, x) → g_M
  30. Gamma(s / 2, 2, x) → g
  31. Gamma(3, β_M, x) → GammaModel
  32. Normal(μ_M, σ_M, x) → NormalModel
  33. Exponential(λ_M, x) → ExpModel
  34. Gamma(3, β, x) → GammaReal
  35. Exponential(λ, x) → ExpReal
  36. Normal(μ, σ, x) → NormalReal
  37. If(SelectedReal ≟ 1, σ, If[SelectedReal ≟ 2, 1 / λ^(2), 3 / β^(2)]) → varReal
  38. If(SelectedReal ≟ 1, μ, If[SelectedReal ≟ 2, 1 / λ, 3 / β]) → meanReal
  39. Element(rulesreal, SelectedReal) → freal
  40. Sort(samplereal) → samplerealord
  41. Element(rulesmodel, SelectedModel) → fmodel
  42. Q1(xpointsModel) → q1Model
  43. Q3(xpointsModel) → q3Model
  44. If(SelectedModel ≟ 1, μ_M, If[SelectedModel ≟ 2, 1 / λ_M, 3 / β_M]) → meanModel
  45. If(SelectedModel ≟ 1, σ_M, If[SelectedModel ≟ 2, 1 / λ_M^(2), 3 / β_M^(2)]) → varModel
  46. Max(x(pointsModel)) → xMaxpointsModel
  47. Translate(Rotate[frealrestrict, 1.5708], (-10, 0)) → gNormSkew
  48. Segment((-10, -2.5), (-10, 5)) → RealpdfAxis
  49. Segment((-9, -2.5), (-9, 5)) → RealsampleAxis
  50. Sequence(Text[i, (-7.9, i - 0.1)], i, -2, 5) → listyyNormSkewRight
  51. Sequence(Text[i, (i - 3.1, -2.9)], i, -4, 4) → listxxNormSkew
  52. Sequence(Text[i, (-7.9, i - 2.1)], i, 0, 7) → listyyExpGamma
  53. Translate(Rotate[frealrestrict, 1.5708], (-10, -2)) → gExpGamma
  54. Segment((-7.5, 2.2), (1.5, 2.2)) → modelaxis
  55. If(SelectedModel ≟ 1, Fnorm, If[SelectedModel ≟ 2, Fexp, If[SelectedModel ≟ 3, Fgamma, If[SelectedModel ≟ 4, FSkewRight, FSkewLeft]]]) → QQpoints
  56. Element(QQpoints, 2) → Min2QQ
  57. Element(pointsModel, 2) → Min2Model
  58. Element(pointsModel, n - 1) → MaxModel
  59. Polygon((x(Corner[1]) + 4.5, y(Corner[1]) + 0.8), (x(Corner[1]), y(Corner[1]) + 0.8), (x(Corner[1]), y(Corner[1])), (x(Corner[1]) + 4.5, y(Corner[1]))) → bottombar, k, l, m, p
  60. Segment(Min2Real, Min2QQ) → A
  61. Segment(Min2QQ, (x(Min2QQ), -4)) → D
  62. Polygon((x(Corner[4]), y(Corner[4])), (x(Corner[4]) + 4.6, y(Corner[4])), (x(Corner[4]) + 4.6, y(Corner[4]) - 0.7), (x(Corner[4]), y(Corner[4]) - 0.7)) → topbar, a_1, c, d, e
  63. Normal(0, 1, x) → Snorm
  64. Polygon((x(Corner[2]) - 5.5, y(Corner[2])), Corner[2], Corner[3] + 1, (x(Corner[3]) - 5.5, y(Corner[3]) + 1)) → sidebar, a, f, h, i
  65. Gamma(s / 2, 0.5, sqrt((2 * s)) + s) → b
  66. Zip(InverseGamma[s / 2, 2, yy], yy, samplereal) → Skewpoints
  67. Sequence(Text[i, (i - 7.1, -2.9)], i, 0, 8) → listxxExpGamma
  68. Segment((-7.5, 0), (1.5, 0)) → xaxisbottom
  69. Sequence(Segment[Element[pointsModel, i], (x(Element[pointsModel, i]), 0)], i, 1, n) → LinesModel
  70. Element(QQpoints, n - 1) → Max2QQ
  71. Segment(Max2Real, Max2QQ) → B
  72. Segment(Max2QQ, (x(Max2QQ), -4)) → E
  73. Segment((x(MaxModel), 3), (x(MaxModel), 2.2)) → L
  74. Segment((x(Min2Model), 3), (x(Min2Model), 2.2)) → J
  75. Sequence(Text[i, (-7.9, i + 3 - 0.1)], i, -5, 2) → listyySkewLeft
  76. FractionText(1 / (n + 1)) → fraction1
  77. FractionText(1 / (n + 1)) → fraction2
  78. Textfield(μ) → μInput
  79. Textfield(σ) → σInput
  80. Textfield(λ) → λInput
  81. Textfield(β) → βInput
  82. Textfield(s) → sInput
  83. Textfield(μ_M) → μ_mInput
  84. Textfield(σ_M) → σ_MInput
  85. Textfield(λ_M) → λ_mInput
  86. Textfield(β_M) → β_mInput
  87. Textfield(s_M) → s_mInput
  88. Polygon((x(Corner[2]) - 5.5, y(Corner[2])), Corner[2], Corner[3] + 1, (x(Corner[3]) - 5.5, y(Corner[3]) + 1)) → sidebar2, j, q, r, t
  89. Textfield(n) → nInput

AI Drawing Prompt Reference

Draw a QQ plot (Quantile-Quantile Plot) to compare two datasets' distributions. The first dataset is generated from random numbers and follows distributions such as normal, gamma, or exponential. The second dataset is the theoretical cumulative distribution function of these distributions. The QQ plot compares data quantiles with theoretical quantiles, showing the similarity between data and theoretical distributions. Construct it by generating random samples, computing quantiles and their cumulative probabilities, and plotting the comparison.
The prompt above was compiled from the original drawing commands and is for reference only.