OH NO! The CS students dozed off mid-code and the design girls are NOT impressed! 😴💻
Time for a WAKE-UP CALL with a proper, engaging, and visually stunning interface that'll keep everyone awake and the statisticians trapped forever!
🎨 The Design Girls' REAL Vision
"We want it to look like a BATTLE ARENA, not a boring spreadsheet!"
- Dark theme with neon accents (very cyberpunk)
- Animated battle effects when estimates clash
- Real-time particle effects for the Monte Carlo simulation
- Sound effects (optional, but epic)
- Responsive design that works on phones too
💥 The ACTUAL Implementation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>⚔️ STATISTICAL WAR ZONE ⚔️</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Orbitron', monospace;
background: linear-gradient(135deg, #0c0c0c 0%, #1a1a2e 50%, #16213e 100%);
color: #00ff88;
overflow-x: hidden;
min-height: 100vh;
}
.war-zone {
position: relative;
min-height: 100vh;
padding: 20px;
}
.title {
text-align: center;
font-size: 3rem;
font-weight: 900;
text-shadow: 0 0 20px #00ff88;
margin-bottom: 30px;
animation: pulse 2s infinite;
}
@keyframes pulse {
0%, 100% { text-shadow: 0 0 20px #00ff88; }
50% { text-shadow: 0 0 40px #00ff88, 0 0 60px #00ff88; }
}
.battle-arena {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 30px;
margin-bottom: 30px;
}
.fighter {
background: rgba(0, 255, 136, 0.1);
border: 2px solid #00ff88;
border-radius: 15px;
padding: 20px;
position: relative;
overflow: hidden;
}
.fighter.bayesian {
border-color: #00bfff;
background: rgba(0, 191, 255, 0.1);
}
.fighter.frequentist {
border-color: #ff6b35;
background: rgba(255, 107, 53, 0.1);
}
.fighter-name {
font-size: 1.5rem;
font-weight: 700;
text-align: center;
margin-bottom: 15px;
}
.bayesian .fighter-name {
color: #00bfff;
text-shadow: 0 0 10px #00bfff;
}
.frequentist .fighter-name {
color: #ff6b35;
text-shadow: 0 0 10px #ff6b35;
}
.stats-display {
display: flex;
justify-content: space-between;
margin-bottom: 15px;
}
.stat {
text-align: center;
}
.stat-value {
font-size: 2rem;
font-weight: 700;
display: block;
}
.battle-canvas {
width: 100%;
height: 200px;
border: 1px solid currentColor;
border-radius: 10px;
background: rgba(0, 0, 0, 0.3);
}
.control-center {
background: rgba(0, 255, 136, 0.1);
border: 2px solid #00ff88;
border-radius: 15px;
padding: 20px;
text-align: center;
margin-bottom: 30px;
}
.controls {
display: flex;
justify-content: center;
gap: 20px;
flex-wrap: wrap;
margin-bottom: 20px;
}
.btn {
background: linear-gradient(45deg, #00ff88, #00cc6a);
border: none;
color: #000;
padding: 15px 30px;
font-family: 'Orbitron', monospace;
font-weight: 700;
font-size: 1rem;
border-radius: 25px;
cursor: pointer;
transition: all 0.3s;
text-transform: uppercase;
}
.btn:hover {
transform: scale(1.05);
box-shadow: 0 0 20px #00ff88;
}
.btn.stop {
background: linear-gradient(45deg, #ff6b35, #ff4500);
}
.input-group {
display: flex;
justify-content: center;
gap: 15px;
flex-wrap: wrap;
}
.input-field {
background: rgba(0, 0, 0, 0.5);
border: 2px solid #00ff88;
color: #00ff88;
padding: 10px;
border-radius: 10px;
font-family: 'Orbitron', monospace;
width: 120px;
text-align: center;
}
.battle-log {
background: rgba(0, 0, 0, 0.7);
border: 2px solid #00ff88;
border-radius: 15px;
padding: 20px;
height: 200px;
overflow-y: auto;
font-family: monospace;
}
.log-entry {
margin-bottom: 5px;
opacity: 0;
animation: fadeIn 0.5s forwards;
}
@keyframes fadeIn {
to { opacity: 1; }
}
.particles {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: -1;
}
.particle {
position: absolute;
width: 2px;
height: 2px;
background: #00ff88;
animation: float 3s infinite linear;
}
@keyframes float {
0% {
transform: translateY(100vh) rotate(0deg);
opacity: 1;
}
100% {
transform: translateY(-10px) rotate(360deg);
opacity: 0;
}
}
@media (max-width: 768px) {
.battle-arena {
grid-template-columns: 1fr;
}
.title {
font-size: 2rem;
}
}
</style>
</head>
<body>
<div class="war-zone">
<div class="particles" id="particles"></div>
<h1 class="title">⚔️ STATISTICAL WAR ZONE ⚔️</h1>
<div class="battle-arena">
<div class="fighter bayesian">
<h2 class="fighter-name">🧠 BAYESIAN</h2>
<div class="stats-display">
<div class="stat">
<span class="stat-value" id="bayesWins">0</span>
<small>Wins</small>
</div>
<div class="stat">
<span class="stat-value" id="bayesAvg">0.000</span>
<small>Avg Estimate</small>
</div>
<div class="stat">
<span class="stat-value" id="bayesAccuracy">0%</span>
<small>Accuracy</small>
</div>
</div>
<canvas class="battle-canvas" id="bayesCanvas"></canvas>
</div>
<div class="fighter frequentist">
<h2 class="fighter-name">📊 FREQUENTIST</h2>
<div class="stats-display">
<div class="stat">
<span class="stat-value" id="freqWins">0</span>
<small>Wins</small>
</div>
<div class="stat">
<span class="stat-value" id="freqAvg">0.000</span>
<small>Avg Estimate</small>
</div>
<div class="stat">
<span class="stat-value" id="freqAccuracy">0%</span>
<small>Accuracy</small>
</div>
</div>
<canvas class="battle-canvas" id="freqCanvas"></canvas>
</div>
</div>
<div class="control-center">
<div class="controls">
<button class="btn" id="startBtn">🚀 START WAR</button>
<button class="btn stop" id="stopBtn" style="display:none;">🛑 CEASE FIRE</button>
<button class="btn" id="resetBtn">🔄 RESET</button>
</div>
<div class="input-group">
<input type="number" class="input-field" id="batchSize" value="50" placeholder="Batch Size">
<input type="number" class="input-field" id="maxRounds" value="10000" placeholder="Max Rounds">
<input type="number" class="input-field" id="speed" value="100" placeholder="Speed (ms)">
</div>
</div>
<div class="battle-log" id="battleLog">
<div class="log-entry">🎯 War Zone Initialized. Ready for battle!</div>
</div>
</div>
<script>
class StatisticalWarZone {
constructor() {
this.isRunning = false;
this.round = 0;
this.bayesData = [];
this.freqData = [];
this.trueValues = [];
this.bayesWins = 0;
this.freqWins = 0;
this.initializeElements();
this.initializeCanvases();
this.createParticles();
this.bindEvents();
}
initializeElements() {
this.startBtn = document.getElementById('startBtn');
this.stopBtn = document.getElementById('stopBtn');
this.resetBtn = document.getElementById('resetBtn');
this.battleLog = document.getElementById('battleLog');
this.batchSizeInput = document.getElementById('batchSize');
this.maxRoundsInput = document.getElementById('maxRounds');
this.speedInput = document.getElementById('speed');
}
initializeCanvases() {
this.bayesCanvas = document.getElementById('bayesCanvas');
this.freqCanvas = document.getElementById('freqCanvas');
this.bayesCtx = this.bayesCanvas.getContext('2d');
this.freqCtx = this.freqCanvas.getContext('2d');
// Set canvas dimensions
[this.bayesCanvas, this.freqCanvas].forEach(canvas => {
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
});
}
createParticles() {
const particlesContainer = document.getElementById('particles');
for (let i = 0; i < 50; i++) {
const particle = document.createElement('div');
particle.className = 'particle';
particle.style.left = Math.random() * 100 + '%';
particle.style.animationDelay = Math.random() * 3 + 's';
particle.style.animationDuration = (Math.random() * 3 + 2) + 's';
particlesContainer.appendChild(particle);
}
}
bindEvents() {
this.startBtn.addEventListener('click', () => this.startWar());
this.stopBtn.addEventListener('click', () => this.stopWar());
this.resetBtn.addEventListener('click', () => this.reset());
}
startWar() {
this.isRunning = true;
this.startBtn.style.display = 'none';
this.stopBtn.style.display = 'inline-block';
this.addLogEntry('⚔️ WAR COMMENCED! Statisticians are battling!');
this.runSimulation();
}
stopWar() {
this.isRunning = false;
this.startBtn.style.display = 'inline-block';
this.stopBtn.style.display = 'none';
this.addLogEntry('🏳️ Ceasefire declared. Battle paused.');
}
reset() {
this.isRunning = false;
this.round = 0;
this.bayesData = [];
this.freqData = [];
this.trueValues = [];
this.bayesWins = 0;
this.freqWins = 0;
this.updateStats();
this.clearCanvases();
this.battleLog.innerHTML = '<div class="log-entry">🎯 War Zone Reset. Ready for new battle!</div>';
this.startBtn.style.display = 'inline-block';
this.stopBtn.style.display = 'none';
}
async runSimulation() {
while (this.isRunning && this.round < parseInt(this.maxRoundsInput.value)) {
await this.simulateBatch();
await this.sleep(parseInt(this.speedInput.value));
}
if (this.round >= parseInt(this.maxRoundsInput.value)) {
this.addLogEntry('🏁 Maximum rounds reached! War concluded.');
this.stopWar();
}
}
async simulateBatch() {
const batchSize = parseInt(this.batchSizeInput.value);
let batchBayesWins = 0;
let batchFreqWins = 0;
for (let i = 0; i < batchSize; i++) {
// Simulate coin flip experiment
const trueP = Math.random();
const nFlips = Math.floor(Math.random() * 45) + 5;
const heads = this.simulateFlips(trueP, nFlips);
// Frequentist estimate
const freqEstimate = heads / nFlips;
// Bayesian estimate (with Beta(1,1) prior)
const bayesEstimate = (heads + 1) / (nFlips + 2);
// Store data
this.bayesData.push(bayesEstimate);
this.freqData.push(freqEstimate);
this.trueValues.push(trueP);
// Determine winner (closer to true value)
const bayesError = Math.abs(bayesEstimate - trueP);
const