Prompt specification
Build or customize the Three.js 3D scene "Wall of null-experiment panels" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Wall of null-experiment panels
Category: Algorithms & Systems · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/wall-of-null-experiment-panels-x1813
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts false positives across multiple statistical tests. Build many small panels showing independent synthetic tests under a stated null model; highlight threshold crossings while labeling every underlying effect zero. Low-poly.
Working Three.js Starter (wall-of-null-experiment-panels-x1813):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>False Positive Field</title>
<style>
:root {
color-scheme: dark;
--bg: #071018;
--panel: rgba(10, 23, 34, 0.86);
--line: rgba(132, 204, 220, 0.18);
--text: #e6f2f5;
--muted: #8da8b2;
--cyan: #70e1d2;
--coral: #ff6b62;
--amber: #ffc866;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#app,
#app canvas {
width: 100%;
height: 100%;
display: block;
}
#app canvas {
touch-action: none;
cursor: grab;
}
#app canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 5;
}
.glass {
background: var(--panel);
border: 1px solid var(--line);
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
.brand {
position: absolute;
top: 18px;
left: 18px;
width: min(390px, calc(100vw - 36px));
padding: 15px 17px 14px;
border-radius: 4px;
}
.kicker {
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 6px 0 7px;
font-size: clamp(24px, 2.2vw, 34px);
line-height: 1;
letter-spacing: -0.035em;
font-weight: 760;
}
.brand p {
margin: 0;
max-width: 350px;
color: var(--muted);
font-size: 11.5px;
line-height: 1.55;
}
.summary {
position: absolute;
top: 18px;
right: 18px;
width: 260px;
padding: 14px 15px;
border-radius: 4px;
}
.summary-title {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
padding-bottom: 10px;
border-bottom: 1px solid var(--line);
}
.summary-title strong {
font-size: 25px;
letter-spacing: -0.04em;
}
.summary-title span {
color: var(--muted);
font-size: 10px;
line-height: 1.35;
text-align: right;
}
.legend {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px 11px;
margin-top: 11px;
color: #b8cbd1;
font-size: 10px;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
}
.swatch {
width: 13px;
height: 13px;
flex: 0 0 auto;
}
.swatch.bar {
background: #244b63;
border: 1px solid #39728a;
}
.swatch.line {
height: 2px;
background: var(--amber);
}
.swatch.reject {
background: var(--coral);
transform: rotate(45deg);
width: 9px;
height: 9px;
margin: 2px;
}
.swatch.keep {
background: var(--cyan);
transform: rotate(45deg);
width: 9px;
height: 9px;
margin: 2px;
}
.note {
margin-top: 11px;
padding-top: 10px;
border-top: 1px solid var(--line);
color: #748e99;
font-size: 9px;
line-height: 1.45;
}
.controls {
position: absolute;
left: 18px;
bottom: 18px;
display: flex;
align-items: center;
gap: 10px;
padding: 9px 10px;
border-radius: 4px;
color: var(--muted);
font-size: 10px;
}
.controls kbd {
padding: 2px 5px;
border: 1px solid rgba(132, 204, 220, 0.24);
border-radius: 3px;
color: #c4d8de;
background: rgba(255, 255, 255, 0.035);
font-family: inherit;
font-size: 9px;
}
#reset {
pointer-events: auto;
border: 1px solid rgba(112, 225, 210, 0.3);
border-radius: 3px;
padding: 6px 9px;
color: var(--cyan);
background: rgba(112, 225, 210, 0.06);
font: 700 9px/1 inherit;
letter-spacing: 0.09em;
cursor: pointer;
}
#reset:hover {
background: rgba(112, 225, 210, 0.13);
}
.inspector {
position: absolute;
right: 18px;
bottom: 18px;
width: 290px;
padding: 14px 15px;
border-radius: 4px;
}
#selectionName {
margin: 6px 0 11px;
font-size: 16px;
font-weight: 750;
letter-spacing: -0.02em;
}
.inspect-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px 12px;
}
.datum {
min-width: 0;
}
.datum.wide {
grid-column: 1 / -1;
}
.datum-label {
display: block;
margin-bottom: 3px;
color: #6f8994;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.datum-value {
display: block;
overflow-wrap: anywhere;
color: #d7e6ea;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10.5px;
line-height: 1.4;
}
#verdict {
font-family: inherit;
font-size: 11px;
font-weight: 800;
}
#verdict.reject {
color: var(--coral);
}
#verdict.keep {
color: var(--cyan);
}
@media (max-width: 800px) {
.summary {
top: auto;
right: 10px;
bottom: 82px;
width: 225px;
}
.brand {
top: 10px;
left: 10px;
width: calc(100vw - 20px);
}
.brand p {
max-width: 90%;
}
.controls {
left: 10px;
bottom: 10px;
}
.inspector {
display: none;
}
.legend,
.note {
display: none;
}
}
</style>
</head>
<body>
<div id="app"></div>
<div class="hud">
<section class="brand glass">
<div class="kicker">Statistical control / Null model</div>
<h1>False Positive Field</h1>
<p>
Independent seeded synthetic tests across eight statistical families.
Every underlying effect is exactly <strong>0.00</strong>. Coral marks a
rejection of a true null.
</p>
</section>
<section class="summary glass">
<div class="summary-title">
<strong id="crossingCount">—</strong>
<span>highlighted<br />threshold crossings</span>
</div>
<div class="legend">
<div class="legend-item">
<span class="swatch bar"></span>
null distribution
</div>
<div class="legend-item">
<span class="swatch line"></span>
α = 0.05 boundary
</div>
<div class="legend-item">
<span class="swatch reject"></span>
false positive
</div>
<div class="legend-item">
<span class="swatch keep"></span>
null retained
</div>
</div>
<div class="note">
Deterministic null draws are curated to expose crossings. The displayed
count is illustrative, not an estimated Type-I error rate.
</div>
</section>
<section class="controls glass">
<span><kbd>drag</kbd> orbit</span>
<span><kbd>shift + drag</kbd> pan</span>
<span><kbd>scroll</kbd> zoom</span>
<span><kbd>click</kbd> inspect</span>
<button id="reset" type="button">RESET VIEW</button>
</section>
<section class="inspector glass">
<div class="kicker">Selected test</div>
<div id="selectionName">Click any panel</div>
<div class="inspect-grid">
<div class="datum">
<span class="datum-label">Observed</span>
<span class="datum-value" id="observed">—</span>
</div>
<div class="datum">
<span class="datum-label">p-value</span>
<span class="datum-value" id="pvalue">—</span>
</div>
<div class="datum">
<span class="datum-label">Boundary</span>
<span class="datum-value" id="boundary">—</span>
</div>
<div class="datum">
<span class="datum-label">True effect</span>
<span class="datum-value" id="effect">0.00</span>
</div>
<div class="datum wide">
<span class="datum-label">Null model</span>
<span class="datum-value" id="model">—</span>
</div>
<div class="datum wide">
<span class="datum-label">Decision</span>
<span class="datum-value" id="verdict">—</span>
</div>
</div>
</section>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene
// -------------------------------------------------------------------------
const app = document.querySelector("#app");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071018);
scene.fog = new THREE.Fog(0x071018, 34, 76);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
150
);
scene.add(new THREE.AmbientLight(0xb9d9e2, 1.15));
const keyLight = new THREE.DirectionalLight(0xd9f5ff, 2.2);
keyLight.position.set(-8, 10, 18);
scene.add(keyLight);
const cyanLight = new THREE.PointLight(0x44d8ca, 30, 50, 2);
cyanLight.position.set(-15, -2, 11);
scene.add(cyanLight);
const coralLight = new THREE.PointLight(0xff5d56, 24, 45, 2);
coralLight.position.set(15, 8, 10);
scene.add(coralLight);
const CARD_W = 3.1;
const CARD_H = 1.72;
const GAP_X = 0.22;
const GAP_Y = 0.22;
const COLS = 8;
const ROWS = 6;
const TOTAL_W = COLS * CARD_W + (COLS - 1) * GAP_X;
const TOTAL_H = ROWS * CARD_H + (ROWS - 1) * GAP_Y;
const GRID_TOP = TOTAL_H / 2;
const cardGeometry = new THREE.BoxGeometry(CARD_W, CARD_H, 0.12);
const cardEdgesGeometry = new THREE.EdgesGeometry(cardGeometry);
const labelGeometry = new THREE.PlaneGeometry(CARD_W - 0.06, CARD_H - 0.06);
const unitBoxGeometry = new THREE.BoxGeometry(1, 1, 1);
const markerStemGeometry = new THREE.CylinderGeometry(1, 1, 1, 5);
const markerHeadGeometry = new THREE.OctahedronGeometry(0.075, 0);
const normalCardMaterial = new THREE.MeshStandardMaterial({
color: 0x0d1b28,
roughness: 0.88,
metalness: 0.04,
flatShading: true
});
const rejectedCardMaterial = new THREE.MeshStandardMaterial({
color: 0x241923,
roughness: 0.9,
metalness: 0.03,
flatShading: true
});
const barMaterial = new THREE.MeshStandardMaterial({
color: 0x244b63,
roughness: 0.92,
metalness: 0.04,
flatShading: true
});
const rejectMaterial = new THREE.MeshStandardMaterial({
color: 0xff6b62,
emissive: 0x5c1514,
emissiveIntensity: 0.8,
roughness: 0.65,
flatShading: true
});
const keepMaterial = new THREE.MeshStandardMaterial({
color: 0x70e1d2,
emissive: 0x0c4a45,
emissiveIntensity: 0.55,
roughness: 0.65,
flatShading: true
});
const thresholdMaterial = new THREE.LineDashedMaterial({
color: 0xffc866,
dashSize: 0.075,
gapSize: 0.045,
transparent: true,
opacity: 0.9
});
const baselineMaterial = new THREE.LineBasicMaterial({
color: 0x315062,
transparent: true,
opacity: 0.55
});
const backboard = new THREE.Mesh(
new THREE.BoxGeometry(TOTAL_W + 0.9, TOTAL_H + 0.9, 0.22),
new THREE.MeshStandardMaterial({
color: 0x09131d,
roughness: 1,
flatShading: true
})
);
backboard.position.z = -0.18;
scene.add(backboard);
const backboardEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(backboard.geometry),
new THREE.LineBasicMaterial({
color: 0x28495a,
transparent: true,
opacity: 0.45
})
);
backboardEdges.position.z = -0.16;
scene.add(backboardEdges);
// -------------------------------------------------------------------------
// Deterministic statistical utilities
// -------------------------------------------------------------------------
const ALPHA = 0.05;
function mulberry32(seed) {
return function () {
let t = (seed += 0x6d2b79f5);
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
function normalRandom(rng) {
const u = Math.max(rng(), 1e-12);
const v = rng();
return Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v);
}
function normalSample(rng, n, mean = 0, sd = 1) {
const values = new Array(n);
for (let i = 0; i < n; i++) {
values[i] = mean + sd * normalRandom(rng);
}
return values;
}
function sampleMean(values) {
return values.reduce((sum, x) => sum + x, 0) / values.length;
}
function sampleVariance(values) {
const mean = sampleMean(values);
return (
values.reduce((sum, x) => sum + (x - mean) ** 2, 0) /
(values.length - 1)
);
}
function correlation(x, y) {
const mx = sampleMean(x);
const my = sampleMean(y);
let numerator = 0;
let dx = 0;
let dy = 0;
for (let i = 0; i < x.length; i++) {
const a = x[i] - mx;
const b = y[i] - my;
numerator += a * b;
dx += a * a;
dy += b * b;
}
return numerator / Math.sqrt(dx * dy);
}
function erf(x) {
const sign = x < 0 ? -1 : 1;
const ax = Math.abs(x);
const t = 1 / (1 + 0.3275911 * ax);
const y =
1 -
((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t -
0.284496736) *
t +
0.254829592) *
t *
Math.exp(-ax * ax);
return sign * y;
}
function normalCdf(x) {
return 0.5 * (1 + erf(x / Math.SQRT2));
}
function normalPdf(x, mean = 0, sd = 1) {
const z = (x - mean) / sd;
return Math.exp(-0.5 * z * z) / (sd * Math.sqrt(2 * Math.PI));
}
function logGamma(z) {
const coefficients = [
0.99999999999980993,
676.5203681218851,
-1259.1392167224028,
771.32342877765313,
-176.61502916214059,
12.507343278686905,
-0.13857109526572012,
9.9843695780195716e-6,
1.5056327351493116e-7
];
if (z < 0.5) {
return (
Math.log(Math.PI) -
Math.log(Math.sin(Math.PI * z)) -
logGamma(1 - z)
);
}
z -= 1;
let x = coefficients[0];
for (let i = 1; i < coefficients.length; i++) {
x += coefficients[i] / (z + i + 1);
}
const t = z + 7.5;
return (
0.5 * Math.log(2 * Math.PI) +
(z + 0.5) * Math.log(t) -
t +
Math.log(x)
);
}
function gammaContinuedFraction(a, x) {
const tiny = 1e-300;
let b = x + 1 - a;
let c = 1 / tiny;
let d = 1 / b;
let h = d;
for (let i = 1; i <= 150; i++) {
const an = -i * (i - a);
b += 2;
d = an * d + b;
if (Math.abs(d) < tiny) d = tiny;
c = b + an / c;
if (Math.abs(c) < tiny) c = tiny;
d = 1 / d;
const delta = d * c;
h *= delta;
if (Math.abs(delta - 1) < 3e-14) break;
}
return h;
}
function regularizedGammaP(a, x) {
if (x <= 0) return 0;
if (x < a + 1) {
let ap = a;
let sum = 1 / a;
let delta = sum;
for (let n = 0; n < 150; n++) {
ap += 1;
delta *= x / ap;
sum += delta;
if (Math.abs(delta) < Math.abs(sum) * 3e-14) break;
}
return (
sum *
Math.exp(-x + a * Math.log(x) - logGamma(a))
);
}
const q =
Math.exp(
-x +
a * Math.log(x) -
logGamma(a) -
Math.log(1e-300)
) * gammaContinuedFraction(a, x);
return 1 - q;
}
function betaContinuedFraction(a, b, x) {
const tiny = 1e-300;
const qab = a + b;
const qap = a + 1;
const qam = a - 1;
let c = 1;
let d = 1 - (qab * x) / qap;
if (Math.abs(d) < tiny) d = tiny;
d = 1 / d;
let h = d;
for (let m = 1; m <= 150; m++) {
const m2 = 2 * m;
let aa = (m * (b - m) * x) / ((qam + m2) * (a + m2));
d = 1 + aa * d;
if (Math.abs(d) < tiny) d = tiny;
c = 1 + aa / c;
if (Math.abs(c) < tiny) c = tiny;
d = 1 / d;
h *= d * c;
aa =
(-(a + m) * (qab + m) * x) /
((a + m2) * (qap + m2));
d = 1 + aa * d;
if (Math.abs(d) < tiny) d = tiny;
c = 1 + aa / c;
if (Math.abs(c) < tiny) c = tiny;
d = 1 / d;
const delta = d * c;
h *= delta;
if (Math.abs(delta - 1) < 3e-14) break;
}
return h;
}
function regularizedBeta(x, a, b) {
if (x <= 0) return 0;
if (x >= 1) return 1;
const logBeta =
logGamma(a + b) - logGamma(a) - logGamma(b);
const front =
Math.exp(
logBeta +
a * Math.log(x) +
b * Math.log(1 - x)
);
if (x < (a + 1) / (a + 2)) {
return (front * betaContinuedFraction(a, b, x)) / a;
}
return (
1 -
(front * betaContinuedFraction(b, a, 1 - x)) / b
);
}
function binomialPmf(n, k, p = 0.5) {
const logCombination =
logGamma(n + 1) - logGamma(k + 1) - logGamma(n - k + 1);
return Math.exp(
logCombination +
k * Math.log(p) +
(n - k) * Math.log(1 - p)
);
}
function binomialTwoSidedP(n, k, p = 0.5) {
const observed = binomialPmf(n, k, p);
let total = 0;
for (let i = 0; i <= n; i++) {
const probability = binomialPmf(n, i, p);
if (probability <= observed + 1e-15) {
total += probability;
}
}
return Math.min(1, total);
}
function shuffleInPlace(values, rng) {
for (let i = values.length - 1; i > 0; i--) {
const j = Math.floor(rng() * (i + 1));
[values[i], values[j]] = [values[j], values[i]];
}
}
function pdfHistogram(pdf, min, max, bins = 13) {
const values = [];
const step = (max - min) / bins;
for (let i = 0; i < bins; i++) {
const x = min + (i + 0.5) * step;
values.push(Math.max(0, pdf(x)));
}
return values;
}
function sampleHistogram(values, min, max, bins = 14) {
const counts = new Array(bins).fill(0);
for (const value of values) {
const index = Math.floor(((value - min) / (max - min)) * bins);
counts[Math.max(0, Math.min(bins - 1, index))] += 1;
}
return counts;
}
function studentTPdf(t, df) {
return (
Math.exp(
logGamma((df + 1) / 2) -
logGamma(df / 2) -
0.5 * Math.log(df * Math.PI)
) *
Math.pow(1 + (t * t) / df, -(df + 1) / 2)
);
}
function chiSquarePdf(x, df) {
if (x <= 0) return 0;
const k = df / 2;
return (
Math.exp(
(k - 1) * Math.log(x) -
x / 2 -
k * Math.log(2) -
logGamma(k)
)
);
}
function fPdf(x, df1, df2) {
if (x <= 0) return 0;
const a = df1 / 2;
const b = df2 / 2;
const logBeta = logGamma(a) + logGamma(b) - logGamma(a + b);
return Math.exp(
a * Math.log(df1 / df2) +
(a - 1) * Math.log(x) -
(a + b) * Math.log(1 + (df1 * x) / df2) -
logBeta
);
}
function ksStatistic(a, b) {
const all = [...a, ...b].sort((x, y) => x - y);
let i = 0;
let j = 0;
let d = 0;
while (i < a.length || j < b.length) {
const value =
j >= b.length
? all[i]
: i >= a.length
? all[j]
: Math.min(all[i], all[j]);
while (i < a.length && all[i] <= value) i++;
while (j < b.length && all[j] <= value) j++;
d = Math.max(d, Math.abs(i / a.length - j / b.length));
}
return d;
}
// -------------------------------------------------------------------------
// Eight test families. All simulated effects are exactly zero.
// -------------------------------------------------------------------------
const familyDefinitions = [
{
key: "z",
name: "ONE-SAMPLE Z TEST",
short: "Z TEST",
nullText: "μ = 0, σ = 1",
modelText: "Xᵢ ~ Normal(0, 1), independently; n = 32",
rejectAt: 0
},
{
key: "t",
name: "ONE-SAMPLE T TEST",
short: "T TEST",
nullText: "μ = 0, σ unknown",
modelText: "Xᵢ ~ Normal(0, σ), independently; n = 14",
rejectAt: 3
},
{
key: "corr",
name: "PEARSON CORRELATION",
short: "PEARSON r",
nullText: "ρ = 0",
modelText: "X and Y are independent Normal(0, 1); n = 22",
rejectAt: 1
},
{
key: "chi",
name: "CHI-SQUARE TEST",
short: "CHI-SQUARE",
nullText: "effect = 0",
modelText: "Six independent standard-normal contributions; df = 6",
rejectAt: 4
},
{
key: "anova",
name: "ONE-WAY ANOVA",
short: "ONE-WAY ANOVA",
nullText: "all Δμ = 0",
modelText: "Five independent Normal(0, σ) groups, five observations each",
rejectAt: 2
},
{
key: "binom",
name: "EXACT BINOMIAL",
short: "EXACT BINOMIAL",
nullText: "p − 0.5 = 0",
modelText: "K ~ Binomial(40, 0.5); exact two-sided test",
rejectAt: 5
},
{
key: "perm",
name: "PERMUTATION MEAN TEST",
short: "PERMUTATION Δ",
nullText: "Δμ = 0",
modelText: "Two Normal(0, σ) groups, n = 14 each; 499 permutations",
rejectAt: 0
},
{
key: "ks",
name: "TWO-SAMPLE KS TEST",
short: "TWO-SAMPLE KS",
nullText: "same distribution",
modelText: "Two independent Normal(0, 1) samples, n = 18 each",
rejectAt: 2
}
];
function simulateFamily(key, seed) {
const rng = mulberry32(seed);
if (key === "z") {
const values = normalSample(rng, 32);
const statistic = Math.sqrt(32) * sampleMean(values);
const p = 2 * (1 - normalCdf(Math.abs(statistic)));
return {
p,
statistic,
statText: `z = ${statistic.toFixed(3)}`,
boundaryText: "|z| ≥ 1.960",
domain: [-4, 4],
observedX: statistic,
thresholdXs: [-1.959963984, 1.959963984],
histogram: pdfHistogram(x => normalPdf(x), -4, 4, 13)
};
}
if (key === "t") {
const values = normalSample(rng, 14);
const df = 13;
const statistic =
sampleMean(values) /
Math.sqrt(sampleVariance(values) / values.length);
const p = regularizedBeta(
df / (df + statistic * statistic),
df / 2,
0.5
);
return {
p,
statistic,
statText: `t = ${statistic.toFixed(3)}`,
boundaryText: "|t| ≥ 2.160",
domain: [-4, 4],
observedX: statistic,
thresholdXs: [-2.160368656, 2.160368656],
histogram: pdfHistogram(
x => studentTPdf(x, df),
-4,
4,
13
)
};
}
if (key === "corr") {
const x = normalSample(rng, 22);
const y = normalSample(rng, 22);
const statistic = Math.max(
-0.999999,
Math.min(0.999999, correlation(x, y))
);
const fisherZ =
0.5 * Math.log((1 + statistic) / (1 - statistic));
const p = 2 * (1 - normalCdf(Math.abs(fisherZ * Math.sqrt(19))));
const critical = Math.tanh(1.959963984 / Math.sqrt(19));
return {
p,
statistic,
statText: `r = ${statistic.toFixed(3)}`,
boundaryText: `|r| ≥ ${critical.toFixed(3)}`,
domain: [-0.8, 0.8],
observedX: statistic,
thresholdXs: [-critical, critical],
histogram: pdfHistogram(
x => normalPdf(x, 0, 0.29),
-0.8,
0.8,
13
)
};
}
if (key === "chi") {
let statistic = 0;
for (let i = 0; i < 6; i++) {
const z = normalRandom(rng);
statistic += z * z;
}
const p = 1 - regularizedGammaP(3, statistic / 2);
return {
p,
statistic,
statText: `χ² = ${statistic.toFixed(3)}`,
boundaryText: "χ² ≥ 10.645",
domain: [0, 20],
observedX: statistic,
thresholdXs: [10.644627],
histogram: pdfHistogram(
x => chiSquarePdf(x, 6),
0,
20,
13
)
};
}
if (key === "anova") {
const groups = Array.from(
{ length: 5 },
() => normalSample(rng, 5)
);
const grandMean = sampleMean(groups.flat());
let between = 0;
let within = 0;
for (const group of groups) {
const mean = sampleMean(group);
between += group.length * (mean - grandMean) ** 2;
for (const value of group) {
within += (value - mean) ** 2;
}
}
const df1 = 4;
const df2 = 20;
const statistic =
(between / df1) / (within / df2);
const p =
1 -
regularizedBeta(
(df1 * statistic) / (df1 * statistic + df2),
df1 / 2,
df2 / 2
);
return {
p,
statistic,
statText: `F = ${statistic.toFixed(3)}`,
boundaryText: "F ≥ 2.866",
domain: [0, 8],
observedX: statistic,
thresholdXs: [2.866080],
histogram: pdfHistogram(
x => fPdf(x, df1, df2),
0,
8,
13
)
};
}
if (key === "binom") {
let successes = 0;
for (let i = 0; i < 40; i++) {
if (rng() < 0.5) successes++;
}
const p = binomialTwoSidedP(40, successes);
let lowCut = 0;
let highCut = 40;
for (let k = 0; k <= 20; k++) {
if (binomialTwoSidedP(40, k) <= ALPHA) lowCut = k;
else break;
}
for (let k = 40; k >= 20; k--) {
if (binomialTwoSidedP(40, k) <= ALPHA) highCut = k;
else break;
}
const histogram = Array.from(
{ length: 40 },
(_, k) => binomialPmf(40, k)
);
return {
p,
statistic: successes,
statText: `K = ${successes}`,
boundaryText: `K ≤ ${lowCut} or K ≥ ${highCut}`,
domain: [0, 40],
observedX: successes,
thresholdXs: [lowCut, highCut],
histogram
};
}
if (key === "perm") {
const a = normalSample(rng, 14);
const b = normalSample(rng, 14);
const combined = [...a, ...b];
const observed =
Math.abs(sampleMean(a) - sampleMean(b));
const nullValues = [];
const permutations = 499;
for (let permutation = 0; permutation < permutations; permutation++) {
shuffleInPlace(combined, rng);
const difference = Math.abs(
sampleMean(combined.slice(0, 14)) -
sampleMean(combined.slice(14))
);
nullValues.push(difference);
}
let exceedances = 0;
for (const value of nullValues) {
if (value >= observed - 1e-12) exceedances++;
}
const p = (exceedances + 1) / (permutations + 1);
const sorted = [...nullValues].sort((x, y) => x - y);
const threshold = sorted[Math.ceil(0.95 * sorted.length) - 1];
const domainMax = Math.max(
threshold * 1.55,
observed * 1.12,
0.001
);
return {
p,
statistic: observed,
statText: `|Δμ| = ${observed.toFixed(3)}`,
boundaryText: `|Δμ| ≥ ${threshold.toFixed(3)}`,
domain: [0, domainMax],
observedX: observed,
thresholdXs: [threshold],
histogram: sampleHistogram(
nullValues,
0,
domainMax,
14
)
};
}
if (key === "ks") {
const a = normalSample(rng, 18);
const b = normalSample(rng, 18);
const statistic = ksStatistic(a, b);
const effectiveN = (18 * 18) / (18 + 18);
const lambda =
(Math.sqrt(effectiveN) +
0.12 +
0.11 / Math.sqrt(effectiveN)) *
statistic;
let kolmogorov = 0;
for (let k = 1; k <= 100; k++) {
const term = Math.exp(-2 * k * k * lambda * lambda);
kolmogorov += (k % 2 === 1 ? term : -term);
if (term < 1e-12) break;
}
const p = Math.max(0, Math.min(1, 2 * kolmogorov));
const threshold =
1.358 /
(Math.sqrt(effectiveN) +
0.12 +
0.11 / Math.sqrt(effectiveN));
const ksPdf = x => {
const scaled = x / 0.8;
if (scaled <= 0 || scaled >= 1) return 0;
return (
30 *
scaled *
Math.pow(1 - scaled, 4) /
0.8
);
};
return {
p,
statistic,
statText: `D = ${statistic.toFixed(3)}`,
boundaryText: `D ≥ ${threshold.toFixed(3)}`,
domain: [0, 0.8],
observedX: statistic,
thresholdXs: [threshold],
histogram: pdfHistogram(ksPdf, 0, 0.8, 13)
};
}
throw new Error(`Unknown family: ${key}`);
}
// Curate one genuine null rejection per family while retaining all
// underlying effect sizes at exactly zero.
const panels = [];
familyDefinitions.forEach((definition, familyIndex) => {
for (let repeat = 0; repeat < 6; repeat++) {
const desiredRejection = repeat === definition.rejectAt;
let seed =
17001 +
familyIndex * 100003 +
repeat * 1009;
let result = null;
for (let attempt = 0; attempt < 8000; attempt++) {
seed += 7919;
result = simulateFamily(definition.key, seed);
if ((result.p <= ALPHA) === desiredRejection) {
break;
}
}
panels.push({
definition,
repeat,
seed,
result,
reject: result.p <= ALPHA
});
}
});
// -------------------------------------------------------------------------
// Panel rendering
// -------------------------------------------------------------------------
const cardMeshes = [];
const animatedMarkers = [];
function pLabel(p) {
if (p < 0.001) return "< 0.001";
return p.toFixed(3);
}
function makePanelTexture(panel, panelNumber) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 352;
const context = canvas.getContext("2d");
const definition = panel.definition;
const result = panel.result;
context.clearRect(0, 0, canvas.width, canvas.height);
context.textBaseline = "top";
context.fillStyle = panel.reject ? "#ff756b" : "#70e1d2";
context.font = "800 25px system-ui, sans-serif";
context.fillText(
`${String(panelNumber).padStart(2, "0")} ${definition.short}`,
24,
20
);
context.fillStyle = "#78939e";
context.font = "15px system-ui, sans-serif";
context.fillText(
`H₀ ${definition.nullText} · seed ${panel.seed}`,
25,
57
);
context.strokeStyle = "rgba(125, 185, 203, 0.16)";
context.lineWidth = 2;
context.beginPath();
context.moveTo(24, 87);
context.lineTo(616, 87);
context.stroke();
context.fillStyle = "#70e1d2";
context.font = "800 18px system-ui, sans-serif";
context.fillText("TRUE EFFECT 0.00", 25, 293);
context.fillStyle = panel.reject ? "#ff756b" : "#70e1d2";
context.font = "800 19px system-ui, sans-serif";
context.textAlign = "right";
context.fillText(
panel.reject ? "REJECT H₀" : "KEEP H₀",
615,
290
);
context.fillStyle = "#8ba4ad";
context.font = "600 16px ui-monospace, monospace";
context.fillText(`p ${pLabel(result.p)}`, 615, 320);
context.textAlign = "left";
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
4,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
function createBanner() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 128;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = "#70e1d2";
context.font = "800 39px system-ui, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(
"EVERY UNDERLYING EFFECT = 0.00",
512,
64
);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false
});
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(8, 1),
material
);
mesh.position.set(0, GRID_TOP + 0.62, 0.02);
scene.add(mesh);
}
createBanner();
function addPanel(panel, panelNumber) {
const group = new THREE.Group();
const column = panelNumber % COLS;
const row = Math.floor(panelNumber / COLS);
group.position.set(
(column - (COLS - 1) / 2) * (CARD_W + GAP_X),
((ROWS - 1) / 2 - row) * (CARD_H + GAP_Y),
0
);
const card = new THREE.Mesh(
cardGeometry,
panel.reject ? rejectedCardMaterial : normalCardMaterial
);
card.userData.panel = panel;
cardMeshes.push(card);
group.add(card);
const borderColor = panel.reject ? 0xff6b62 : 0x2c6575;
const borderMaterial = new THREE.LineBasicMaterial({
color: borderColor,
transparent: true,
opacity: 0.78
});
const border = new THREE.LineSegments(
cardEdgesGeometry,
borderMaterial
);
border.userData.baseColor = borderColor;
group.add(border);
const labelMaterial = new THREE.MeshBasicMaterial({
map: makePanelTexture(panel, panelNumber + 1),
transparent: true,
depthWrite: false
});
const label = new THREE.Mesh(labelGeometry, labelMaterial);
label.position.z = 0.071;
group.add(label);
const result = panel.result;
const [domainMin, domainMax] = result.domain;
const plotWidth = 2.62;
const plotLeft = -1.31;
const baseline = -0.075;
const plotHeight = 0.45;
const mapX = value =>
plotLeft +
((value - domainMin) / (domainMax - domainMin)) * plotWidth;
const histogram = result.histogram;
const maximum = Math.max(...histogram, 1e-12);
const barWidth =
(plotWidth / histogram.length) * 0.72;
histogram.forEach((value, index) => {
const height = (value / maximum) * plotHeight;
const center =
domainMin +
((index + 0.5) / histogram.length) *
(domainMax - domainMin);
const bar = new THREE.Mesh(
unitBoxGeometry,
barMaterial
);
bar.position.set(
mapX(center),
baseline + height / 2,
0.11
);
bar.scale.set(barWidth, height, 0.035);
group.add(bar);
});
const baselineGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(plotLeft, baseline, 0.12),
new THREE.Vector3(plotLeft + plotWidth, baseline, 0.12)
]);
group.add(
new THREE.Line(baselineGeometry, baselineMaterial)
);
for (const threshold of result.thresholdXs) {
const x = mapX(threshold);
const geometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(x, baseline, 0.16),
new THREE.Vector3(x, baseline + plotHeight, 0.16)
]);
const line = new THREE.Line(
geometry,
thresholdMaterial
);
line.computeLineDistances();
group.add(line);
}
const observedX = mapX(
THREE.MathUtils.clamp(
result.observedX,
domainMin,
domainMax
)
);
const markerMaterial = panel.reject
? rejectMaterial
: keepMaterial;
const stemHeight = plotHeight * 0.88;
const stem = new THREE.Mesh(
markerStemGeometry,
markerMaterial
);
stem.position.set(
observedX,
baseline + stemHeight / 2,
0.19
);
stem.scale.set(0.017, stemHeight, 0.017);
group.add(stem);
const head = new THREE.Mesh(
markerHeadGeometry,
markerMaterial
);
head.position.set(
observedX,
baseline + stemHeight,
0.20
);
group.add(head);
if (panel.reject) {
animatedMarkers.push(head);
}
scene.add(group);
}
panels.forEach(addPanel);
const crossingCount = panels.filter(panel => panel.reject).length;
document.querySelector("#crossingCount").textContent =
`${crossingCount} / ${panels.length}`;
// -------------------------------------------------------------------------
// Direct camera controls: orbit, pan, zoom, reset, and panel picking
// -------------------------------------------------------------------------
const view = {
yaw: 0,
pitch: 0.035,
zoom: 1,
fitDistance: 25,
target: new THREE.Vector3(0, 0.35, 0)
};
function computeFitDistance() {
const fitWidth = TOTAL_W + 2.3;
const fitHeight = TOTAL_H + 4.6;
const tangent = Math.tan(
THREE.MathUtils.degToRad(camera.fov * 0.5)
);
const vertical = fitHeight / (2 * tangent);
const horizontal =
fitWidth / (2 * tangent * camera.aspect);
return Math.max(vertical, horizontal) * 1.08;
}
function updateCamera() {
const distance = view.fitDistance * view.zoom;
const horizontalDistance =
Math.cos(view.pitch) * distance;
camera.position.set(
view.target.x + Math.sin(view.yaw) * horizontalDistance,
view.target.y + Math.sin(view.pitch) * distance,
view.target.z + Math.cos(view.yaw) * horizontalDistance
);
camera.lookAt(view.target);
}
function resetView() {
view.yaw = 0;
view.pitch = 0.035;
view.zoom = 1;
view.target.set(0, 0.35, 0);
updateCamera();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setPixelRatio(
Math.min(window.devicePixelRatio, 1.8)
);
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
view.fitDistance = computeFitDistance();
updateCamera();
}
window.addEventListener("resize", resize);
resize();
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let selectedBorder = null;
let drag = null;
function hitTest(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x =
((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y =
-((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(cardMeshes, false);
return hits.length ? hits[0].object : null;
}
function selectPanel(card) {
if (!card) return;
if (selectedBorder) {
selectedBorder.material.color.set(
selectedBorder.userData.baseColor
);
}
selectedBorder = card.parent.children.find(
child => child.isLineSegments
);
selectedBorder?.material.color.set(0xffffff);
const panel = card.userData.panel;
const result = panel.result;
document.querySelector("#selectionName").textContent =
`${panel.definition.name} / ${panel.repeat + 1}`;
document.querySelector("#observed").textContent =
result.statText;
document.querySelector("#pvalue").textContent =
pLabel(result.p);
document.querySelector("#boundary").textContent =
result.boundaryText;
document.querySelector("#effect").textContent =
"0.00";
document.querySelector("#model").textContent =
panel.definition.modelText;
const verdict = document.querySelector("#verdict");
verdict.className =
`datum-value ${panel.reject ? "reject" : "keep"}`;
verdict.textContent = panel.reject
? "FALSE POSITIVE — reject the true null"
: "NULL RETAINED — no threshold crossing";
}
renderer.domElement.addEventListener("pointerdown", event => {
renderer.domElement.setPointerCapture(event.pointerId);
drag = {
startX: event.clientX,
startY: event.clientY,
lastX: event.clientX,
lastY: event.clientY,
moved: false,
pan: event.shiftKey
};
});
renderer.domElement.addEventListener("pointermove", event => {
if (!drag) {
renderer.domElement.style.cursor = hitTest(event)
? "pointer"
: "grab";
return;
}
const dx = event.clientX - drag.lastX;
const dy = event.clientY - drag.lastY;
if (
Math.hypot(
event.clientX - drag.startX,
event.clientY - drag.startY
) > 4
) {
drag.moved = true;
}
if (drag.pan) {
const scale = view.fitDistance * view.zoom * 0.001;
view.target.x = THREE.MathUtils.clamp(
view.target.x - dx * scale,
-12,
12
);
view.target.y = THREE.MathUtils.clamp(
view.target.y + dy * scale,
-7,
7
);
} else {
view.yaw -= dx * 0.004;
view.pitch = THREE.MathUtils.clamp(
view.pitch + dy * 0.003,
-0.42,
0.42
);
}
drag.lastX = event.clientX;
drag.lastY = event.clientY;
updateCamera();
});
renderer.domElement.addEventListener("pointerup", event => {
if (drag && !drag.moved) {
selectPanel(hitTest(event));
}
drag = null;
});
renderer.domElement.addEventListener("pointercancel", () => {
drag = null;
});
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
view.zoom = THREE.MathUtils.clamp(
view.zoom * Math.exp(event.deltaY * 0.001),
0.55,
2.15
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
document.querySelector("#reset").addEventListener(
"click",
resetView
);
window.addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") {
resetView();
}
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
function animate() {
const elapsed = clock.getElapsedTime();
if (!reducedMotion) {
for (let i = 0; i < animatedMarkers.length; i++) {
const pulse = 1 + Math.sin(elapsed * 3.1 + i * 0.9) * 0.12;
animatedMarkers[i].scale.setScalar(pulse);
}
}
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```