Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
AltmannPeter authored Jul 28, 2023
1 parent 9e826e8 commit 931952f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ initializeTableWithSampleData();
function calculateBitVectorAnalysis() {
const coinBiasInput = document.getElementById("coin-bias");
const coinBias = parseFloat(coinBiasInput.value.trim());
const asr = numBits * probabilityOfOne * 128 / 8; // Convert bits to bytes

analysisData.push({ bias: coinBias, entropy: shannonEntropy, compressedSize: compressedSizeInBytes, asr: asr });

if (isNaN(coinBias) || coinBias < 0 || coinBias > 100) {
document.getElementById("result").textContent = "Please enter a valid probability of 1 (between 0 and 100%).";
Expand Down Expand Up @@ -86,20 +89,24 @@ function calculateBitVectorAnalysis() {
function updateTable() {
const tableBody = document.getElementById("analysis-table");
tableBody.innerHTML = "";



analysisData.forEach((data) => {
const row = document.createElement("tr");
const biasCell = document.createElement("td");
const entropyCell = document.createElement("td");
const compressedSizeCell = document.createElement("td");
const asrCell = document.createElement("td");

biasCell.textContent = data.bias.toFixed(2) + "%";
entropyCell.textContent = data.entropy.toFixed(4);
compressedSizeCell.textContent = data.compressedSize.toLocaleString();
asrCell.textContent = data.asr.toFixed(2);

row.appendChild(biasCell);
row.appendChild(entropyCell);
row.appendChild(compressedSizeCell);
row.appendChild(asrCell);
tableBody.appendChild(row);
});
}
Expand Down

0 comments on commit 931952f

Please sign in to comment.