Code
viewof true_mu = {
const input = Inputs.range([-2, 5], {value: 2, step: 0.5, label: "True ฮผ (%):"});
['pointerdown','touchstart','mousedown','click','wheel','pointermove','touchmove']
.forEach(e => input.addEventListener(e, ev => ev.stopPropagation()));
return input;
}
viewof sigma_val = {
const input = Inputs.range([1, 8], {value: 3, step: 0.5, label: "Std Dev ฯ (%):"});
['pointerdown','touchstart','mousedown','click','wheel','pointermove','touchmove']
.forEach(e => input.addEventListener(e, ev => ev.stopPropagation()));
return input;
}
viewof n_paths = {
const input = Inputs.range([1, 30], {value: 10, step: 1, label: "# Sequences:"});
['pointerdown','touchstart','mousedown','click','wheel','pointermove','touchmove']
.forEach(e => input.addEventListener(e, ev => ev.stopPropagation()));
return input;
}
consistencyInfo = {
const finalVals = [];
for (let p = 0; p < n_paths; p++) {
let sum = 0;
for (let i = 1; i <= 200; i++) {
const u1 = Math.random(), u2 = Math.random();
const z = Math.sqrt(-2*Math.log(u1)) * Math.cos(2*Math.PI*u2);
sum += true_mu + sigma_val * z;
}
finalVals.push(sum / 200);
}
const avg = finalVals.reduce((a,b)=>a+b,0)/finalVals.length;
const spread = Math.max(...finalVals) - Math.min(...finalVals);
return html`<div style="background:#e8f4f8; padding:8px; border-radius:6px; font-size:0.9em;">
<strong>At n = 200:</strong><br>
Avg estimate: ${avg.toFixed(3)}%<br>
True ฮผ: ${true_mu}%<br>
Range of paths: ${spread.toFixed(3)}%
</div>`;
}
