A small static web app / mini-game that shows a scatter plot and challenges the player to estimate three correlation measures:
- Pearson's r
- Spearman's rho (rank correlation)
- Kendall's tau
Win condition: all three estimates are within ±0.1 (configurable) of the actual values computed from the generated dataset.
This repository contains a lightweight, dependency-minimal implementation that runs entirely in the browser and is ready to be hosted on GitHub Pages or any static hosting.
- A ready-to-run static web app with:
- index.html (UI + Chart.js from CDN)
- style.css (simple responsive styling)
- app.js (data generation, statistical computations, game logic, plotting)
- A clear README with how it works and how to run it locally or deploy.
Scroll down for usage, customization notes, and the exact file contents included below.
- Clone or download the files to a folder.
- Open
index.htmlin your browser (or push to GitHub and enable Pages). - The app shows a scatter plot. Enter your estimates for Pearson r, Spearman rho, and Kendall tau and click "Submit".
- If each estimate is within ±0.1 (default), you win. The app shows the actual values and feedback.
- Click "New Plot" to generate another dataset.
- Data generation uses a bivariate-normal construction so you can control the true Pearson correlation (randomized each round).
- Pearson, Spearman, and Kendall calculations are implemented in plain JavaScript (no server).
- Score checking is numeric and tolerant: you can configure the win threshold.
- Plotting via Chart.js CDN for a simple interactive scatter visualization.
- Mobile-friendly and accessible UI controls.
- Pearson's r: covariance / (sd_x * sd_y).
- Spearman's rho: Pearson's r computed on ranks of x and y.
- Kendall's tau: (C - D) / (n*(n-1)/2) where C is concordant pair count and D is discordant pair count (ties handled simply).
- Dataset generation: x ~ N(0,1); y = rho * x + sqrt(1 - rho^2) * e (e ~ N(0,1)). This yields sample correlations near the specified rho.
- Change sample size (default 50) in
app.js. - Change the allowed error threshold (default ±0.1) with the "Tolerance" control.
- Add difficulty levels (smaller tolerance, smaller sample size).
- Replace Chart.js with D3 for richer interactions if desired.
- Add scoreboard, timer, or multiplayer.
- index.html
- style.css
- app.js
(Each file content is included in the repo root — see above.)
MIT
Thanks — I created a complete static web app you can run immediately.