<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Randomized Algorithm Potency Tracker</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background-color: #f4f7f6;
color: #333;
max-width: 800px;
margin: 40px auto;
padding: 20px;
}
h1 {
color: #2c3e50;
border-bottom: 2px solid #e2e8f0;
padding-bottom: 10px;
}
.control-panel {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
margin-bottom: 20px;
display: flex;
gap: 20px;
align-items: flex-end;
}
.input-group {
display: flex;
flex-direction: column;
gap: 5px;
}
label {
font-weight: bold;
font-size: 0.9rem;
color: #4a5568;
}
input {
padding: 8px 12px;
border: 1px solid #cbd5e1;
border-radius: 4px;
font-size: 1rem;
width: 120px;
}
button {
padding: 9px 20px;
background-color: #3182ce;
color: white;
border: none;
border-radius: 4px;
font-size: 1rem;
cursor: pointer;
font-weight: bold;
transition: background-color 0.2s;
}
button:hover {
background-color: #2b6cb0;
}
table {
width: 100%;
border-collapse: collapse;
background-color: #fff;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
th, td {
padding: 12px 15px;
text-align: left;
}
th {
background-color: #edf2f7;
color: #4a5568;
font-weight: bold;
border-bottom: 2px solid #cbd5e1;
}
tr:nth-child(even) {
background-color: #f7fafc;
}
tr:border-bottom {
border-bottom: 1px solid #e2e8f0;
}
</style>
</head>
<body>
<h1>Potency Analysis Tracker</h1>
<p>Simulating the efficiency of picking the best route out of an exponentially large path combo space using random samples.</p>
<div class="control-panel">
<div class="input-group">
<label for="initialRs">Starting rs:</label>
<input type="number" id="initialRs" value="4" min="1">
</div>
<div class="input-group">
<label for="rangePower">Range (n for 2^n):</label>
<input type="number" id="rangePower" value="20" min="1" max="30">
</div>
<button onclick="runAnalysis()">Run Simulation</button>
</div>
<table>
<thead>
<tr>
<th>rs (Sample Size)</th>
<th>Total Combinations (2^n)</th>
<th>Average Quality Percentile</th>
</tr>
</thead>
<tbody id="resultsTableBody">
</tbody>
</table>
<script>
function runAnalysis() {
// Grab values from user input
let rs = parseInt(document.getElementById('initialRs').value) || 4;
const n = parseInt(document.getElementById('rangePower').value) || 20;
const TOTAL_COMBINATIONS = Math.pow(2, n);
const ITERATIONS = 100;
const tableBody = document.getElementById('resultsTableBody');
// Clear previous results
tableBody.innerHTML = "";
// Loop until rs exceeds 1000
while (rs <= 1024) {
let totalPercentile = 0;
for (let i = 0; i < ITERATIONS; i++) {
let smallestRank = TOTAL_COMBINATIONS;
for (let s = 0; s < rs; s++) {
let randomRank = Math.floor(Math.random() * TOTAL_COMBINATIONS) + 1;
if (randomRank < smallestRank) {
smallestRank = randomRank;
}
}
let percentile = ((TOTAL_COMBINATIONS - smallestRank) / TOTAL_COMBINATIONS) * 100;
totalPercentile += percentile;
}
let averagePercentile = totalPercentile / ITERATIONS;
// Create a table row for the current rs value
const row = document.createElement('tr');
row.innerHTML = `
<td><strong>${rs}</strong></td>
<td>${TOTAL_COMBINATIONS.toLocaleString()}</td>
<td>${averagePercentile.toFixed(4)}%</td>
`;
tableBody.appendChild(row);
// Multiply rs by 2 as dictated by the shortcut rules
rs *= 2;
}
}
// Run once automatically on page load
window.onload = runAnalysis;
</script>
</body>
</html>