Update index.html
Browse files- index.html +106 -18
index.html
CHANGED
@@ -1,19 +1,107 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
</html>
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<title>Gradient-Free BOED via Interacting Particle Systems</title>
|
6 |
+
<style>
|
7 |
+
body { margin: 0; overflow: hidden; }
|
8 |
+
#info {
|
9 |
+
position: absolute;
|
10 |
+
top: 10px; left: 10px;
|
11 |
+
color: #fff;
|
12 |
+
font-family: sans-serif;
|
13 |
+
background: rgba(0,0,0,0.4);
|
14 |
+
padding: 8px 12px;
|
15 |
+
border-radius: 4px;
|
16 |
+
font-size: 14px;
|
17 |
+
}
|
18 |
+
</style>
|
19 |
+
</head>
|
20 |
+
<body>
|
21 |
+
<div id="info">
|
22 |
+
<strong>Particles:</strong> Ensemble Kalman Inversion (attraction to mean)<br/>
|
23 |
+
<strong>Noise:</strong> Affine-Invariant Langevin Dynamics
|
24 |
+
</div>
|
25 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script>
|
26 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/controls/OrbitControls.js"></script>
|
27 |
+
<script>
|
28 |
+
// --- SCENE SETUP ---
|
29 |
+
let scene = new THREE.Scene();
|
30 |
+
let camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);
|
31 |
+
camera.position.set(0, 0, 50);
|
32 |
+
|
33 |
+
let renderer = new THREE.WebGLRenderer({ antialias: true });
|
34 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
35 |
+
document.body.appendChild(renderer.domElement);
|
36 |
+
|
37 |
+
let controls = new THREE.OrbitControls(camera, renderer.domElement);
|
38 |
+
|
39 |
+
window.addEventListener('resize', () => {
|
40 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
41 |
+
camera.updateProjectionMatrix();
|
42 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
43 |
+
});
|
44 |
+
|
45 |
+
// --- PARTICLE SYSTEM PARAMETERS ---
|
46 |
+
const PARTICLE_COUNT = 100;
|
47 |
+
const particles = [];
|
48 |
+
const geometry = new THREE.SphereGeometry(0.5, 8, 8);
|
49 |
+
|
50 |
+
// Initialize particles with random positions
|
51 |
+
for (let i = 0; i < PARTICLE_COUNT; i++) {
|
52 |
+
let material = new THREE.MeshBasicMaterial({
|
53 |
+
color: new THREE.Color(Math.random(), Math.random(), Math.random())
|
54 |
+
});
|
55 |
+
let p = new THREE.Mesh(geometry, material);
|
56 |
+
p.position.set(
|
57 |
+
(Math.random() - 0.5) * 40,
|
58 |
+
(Math.random() - 0.5) * 40,
|
59 |
+
(Math.random() - 0.5) * 40
|
60 |
+
);
|
61 |
+
particles.push(p);
|
62 |
+
scene.add(p);
|
63 |
+
}
|
64 |
+
|
65 |
+
// --- UPDATE LOOP ---
|
66 |
+
function updateParticles() {
|
67 |
+
// 1) Compute ensemble mean
|
68 |
+
let mean = new THREE.Vector3();
|
69 |
+
particles.forEach(p => mean.add(p.position));
|
70 |
+
mean.divideScalar(PARTICLE_COUNT);
|
71 |
+
|
72 |
+
// 2) Compute a rough measure of covariance (average squared distance)
|
73 |
+
let cov = 0;
|
74 |
+
particles.forEach(p => cov += p.position.distanceToSquared(mean));
|
75 |
+
cov /= PARTICLE_COUNT;
|
76 |
+
|
77 |
+
// 3) For each particle: apply EKI‐style attraction + ALDI noise
|
78 |
+
const attractionStrength = 0.01;
|
79 |
+
const noiseScale = 0.1 * Math.sqrt(cov);
|
80 |
+
|
81 |
+
particles.forEach(p => {
|
82 |
+
// Attraction toward mean (EKI)
|
83 |
+
let toMean = mean.clone().sub(p.position).multiplyScalar(attractionStrength);
|
84 |
+
|
85 |
+
// Affine-Invariant Langevin noise
|
86 |
+
let noise = new THREE.Vector3(
|
87 |
+
(Math.random() - 0.5),
|
88 |
+
(Math.random() - 0.5),
|
89 |
+
(Math.random() - 0.5)
|
90 |
+
).multiplyScalar(noiseScale);
|
91 |
+
|
92 |
+
// Update position
|
93 |
+
p.position.add(toMean).add(noise);
|
94 |
+
});
|
95 |
+
}
|
96 |
+
|
97 |
+
// --- RENDER LOOP ---
|
98 |
+
function animate() {
|
99 |
+
requestAnimationFrame(animate);
|
100 |
+
updateParticles();
|
101 |
+
controls.update();
|
102 |
+
renderer.render(scene, camera);
|
103 |
+
}
|
104 |
+
animate();
|
105 |
+
</script>
|
106 |
+
</body>
|
107 |
</html>
|