Spaces:
Running
Running
on Statistics, Programmer, Financial currenlty its showng nothing add al the advance feature on this
Browse files- index.html +245 -13
index.html
CHANGED
|
@@ -139,7 +139,6 @@
|
|
| 139 |
<button class="calculator-btn bg-secondary hover:bg-purple-600 text-white font-bold py-4 rounded-xl" onclick="calculateResult()">=</button>
|
| 140 |
<button class="calculator-btn bg-primary hover:bg-indigo-600 text-white font-bold py-4 rounded-xl" onclick="appendToDisplay('+')">+</button>
|
| 141 |
</div>
|
| 142 |
-
|
| 143 |
<!-- Statistics Calculator -->
|
| 144 |
<div id="statisticsCalculator" class="hidden">
|
| 145 |
<div class="result-display">
|
|
@@ -170,8 +169,6 @@
|
|
| 170 |
<span>Median:</span>
|
| 171 |
<span id="statMedian" class="font-bold">0</span>
|
| 172 |
</div>
|
| 173 |
-
</div>
|
| 174 |
-
<div>
|
| 175 |
<div class="flex justify-between mb-2">
|
| 176 |
<span>Mode:</span>
|
| 177 |
<span id="statMode" class="font-bold">0</span>
|
|
@@ -180,6 +177,8 @@
|
|
| 180 |
<span>Range:</span>
|
| 181 |
<span id="statRange" class="font-bold">0</span>
|
| 182 |
</div>
|
|
|
|
|
|
|
| 183 |
<div class="flex justify-between mb-2">
|
| 184 |
<span>Variance:</span>
|
| 185 |
<span id="statVariance" class="font-bold">0</span>
|
|
@@ -188,12 +187,30 @@
|
|
| 188 |
<span>Std Deviation:</span>
|
| 189 |
<span id="statStdDev" class="font-bold">0</span>
|
| 190 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
</div>
|
| 192 |
</div>
|
| 193 |
</div>
|
|
|
|
|
|
|
|
|
|
| 194 |
</div>
|
| 195 |
</div>
|
| 196 |
-
|
| 197 |
<!-- Programmer Calculator -->
|
| 198 |
<div id="programmerCalculator" class="hidden">
|
| 199 |
<div class="result-display">
|
|
@@ -238,9 +255,25 @@
|
|
| 238 |
</div>
|
| 239 |
<div class="mt-2 text-center font-bold" id="bitwiseResult">Result: 0</div>
|
| 240 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
</div>
|
| 242 |
</div>
|
| 243 |
-
|
| 244 |
<!-- Financial Calculator -->
|
| 245 |
<div id="financialCalculator" class="hidden">
|
| 246 |
<div class="result-display">
|
|
@@ -269,10 +302,10 @@
|
|
| 269 |
</div>
|
| 270 |
</div>
|
| 271 |
<div class="grid grid-cols-2 gap-4 mb-4">
|
| 272 |
-
<button class="calculator-btn bg-primary hover:bg-indigo-600 text-white font-bold py-3 rounded-xl" onclick="calculateCompoundInterest()">Calculate</button>
|
| 273 |
<button class="calculator-btn bg-gray-700 hover:bg-gray-600 text-white font-bold py-3 rounded-xl" onclick="clearFinancial()">Clear</button>
|
| 274 |
</div>
|
| 275 |
-
<div class="bg-gray-100 rounded-xl p-4">
|
| 276 |
<div class="flex justify-between mb-2">
|
| 277 |
<span>Future Value:</span>
|
| 278 |
<span id="futureValue" class="font-bold">$1,280.08</span>
|
|
@@ -286,6 +319,42 @@
|
|
| 286 |
<span id="apyRate" class="font-bold">5.12%</span>
|
| 287 |
</div>
|
| 288 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
</div>
|
| 290 |
</div>
|
| 291 |
</div>
|
|
@@ -890,7 +959,6 @@
|
|
| 890 |
}
|
| 891 |
document.getElementById('matrixResult').innerHTML = 'Result will appear here';
|
| 892 |
}
|
| 893 |
-
|
| 894 |
// Statistics functions
|
| 895 |
function calculateStatistics() {
|
| 896 |
const dataInput = document.getElementById('dataSet').value;
|
|
@@ -907,7 +975,7 @@
|
|
| 907 |
return;
|
| 908 |
}
|
| 909 |
|
| 910 |
-
// Calculate statistics
|
| 911 |
const count = dataArray.length;
|
| 912 |
const sum = dataArray.reduce((acc, num) => acc + num, 0);
|
| 913 |
const mean = sum / count;
|
|
@@ -946,6 +1014,18 @@
|
|
| 946 |
const variance = squaredDifferences.reduce((acc, val) => acc + val, 0) / count;
|
| 947 |
const stdDev = Math.sqrt(variance);
|
| 948 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 949 |
// Update UI
|
| 950 |
document.getElementById('statCount').textContent = count;
|
| 951 |
document.getElementById('statSum').textContent = sum.toFixed(2);
|
|
@@ -955,11 +1035,78 @@
|
|
| 955 |
document.getElementById('statRange').textContent = range.toFixed(2);
|
| 956 |
document.getElementById('statVariance').textContent = variance.toFixed(4);
|
| 957 |
document.getElementById('statStdDev').textContent = stdDev.toFixed(4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 958 |
} catch (error) {
|
| 959 |
alert("Error calculating statistics: " + error.message);
|
| 960 |
}
|
| 961 |
}
|
| 962 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 963 |
function clearStatistics() {
|
| 964 |
document.getElementById('dataSet').value = '';
|
| 965 |
document.getElementById('statCount').textContent = '0';
|
|
@@ -970,9 +1117,16 @@
|
|
| 970 |
document.getElementById('statRange').textContent = '0';
|
| 971 |
document.getElementById('statVariance').textContent = '0';
|
| 972 |
document.getElementById('statStdDev').textContent = '0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 973 |
}
|
| 974 |
-
|
| 975 |
-
// Programmer functions
|
| 976 |
function convertNumberSystems() {
|
| 977 |
const decInput = document.getElementById('decInput');
|
| 978 |
const binInput = document.getElementById('binInput');
|
|
@@ -1006,7 +1160,6 @@
|
|
| 1006 |
// Invalid input - do nothing
|
| 1007 |
}
|
| 1008 |
}
|
| 1009 |
-
|
| 1010 |
function performBitwise(operation) {
|
| 1011 |
const num1 = parseInt(document.getElementById('bitNum1').value) || 0;
|
| 1012 |
const num2 = parseInt(document.getElementById('bitNum2').value) || 0;
|
|
@@ -1032,6 +1185,56 @@
|
|
| 1032 |
document.getElementById('bitwiseResult').textContent = `Result: ${result} (0b${result.toString(2)})`;
|
| 1033 |
}
|
| 1034 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1035 |
// Financial functions
|
| 1036 |
function calculateCompoundInterest() {
|
| 1037 |
const principal = parseFloat(document.getElementById('principal').value) || 0;
|
|
@@ -1052,6 +1255,26 @@
|
|
| 1052 |
document.getElementById('apyRate').textContent = `${apy.toFixed(2)}%`;
|
| 1053 |
}
|
| 1054 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1055 |
function clearFinancial() {
|
| 1056 |
document.getElementById('principal').value = '1000';
|
| 1057 |
document.getElementById('interestRate').value = '5';
|
|
@@ -1062,7 +1285,16 @@
|
|
| 1062 |
document.getElementById('apyRate').textContent = '5.12%';
|
| 1063 |
}
|
| 1064 |
|
| 1065 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1066 |
function initializeChart() {
|
| 1067 |
const ctx = document.getElementById('functionChart').getContext('2d');
|
| 1068 |
functionChart = new Chart(ctx, {
|
|
|
|
| 139 |
<button class="calculator-btn bg-secondary hover:bg-purple-600 text-white font-bold py-4 rounded-xl" onclick="calculateResult()">=</button>
|
| 140 |
<button class="calculator-btn bg-primary hover:bg-indigo-600 text-white font-bold py-4 rounded-xl" onclick="appendToDisplay('+')">+</button>
|
| 141 |
</div>
|
|
|
|
| 142 |
<!-- Statistics Calculator -->
|
| 143 |
<div id="statisticsCalculator" class="hidden">
|
| 144 |
<div class="result-display">
|
|
|
|
| 169 |
<span>Median:</span>
|
| 170 |
<span id="statMedian" class="font-bold">0</span>
|
| 171 |
</div>
|
|
|
|
|
|
|
| 172 |
<div class="flex justify-between mb-2">
|
| 173 |
<span>Mode:</span>
|
| 174 |
<span id="statMode" class="font-bold">0</span>
|
|
|
|
| 177 |
<span>Range:</span>
|
| 178 |
<span id="statRange" class="font-bold">0</span>
|
| 179 |
</div>
|
| 180 |
+
</div>
|
| 181 |
+
<div>
|
| 182 |
<div class="flex justify-between mb-2">
|
| 183 |
<span>Variance:</span>
|
| 184 |
<span id="statVariance" class="font-bold">0</span>
|
|
|
|
| 187 |
<span>Std Deviation:</span>
|
| 188 |
<span id="statStdDev" class="font-bold">0</span>
|
| 189 |
</div>
|
| 190 |
+
<div class="flex justify-between mb-2">
|
| 191 |
+
<span>Quartile Q1:</span>
|
| 192 |
+
<span id="statQ1" class="font-bold">0</span>
|
| 193 |
+
</div>
|
| 194 |
+
<div class="flex justify-between mb-2">
|
| 195 |
+
<span>Quartile Q3:</span>
|
| 196 |
+
<span id="statQ3" class="font-bold">0</span>
|
| 197 |
+
</div>
|
| 198 |
+
<div class="flex justify-between mb-2">
|
| 199 |
+
<span>Interquartile Range:</span>
|
| 200 |
+
<span id="statIQR" class="font-bold">0</span>
|
| 201 |
+
</div>
|
| 202 |
+
<div class="flex justify-between mb-2">
|
| 203 |
+
<span>Skewness:</span>
|
| 204 |
+
<span id="statSkewness" class="font-bold">0</span>
|
| 205 |
+
</div>
|
| 206 |
</div>
|
| 207 |
</div>
|
| 208 |
</div>
|
| 209 |
+
<div class="mt-4">
|
| 210 |
+
<canvas id="statisticsChart" height="200"></canvas>
|
| 211 |
+
</div>
|
| 212 |
</div>
|
| 213 |
</div>
|
|
|
|
| 214 |
<!-- Programmer Calculator -->
|
| 215 |
<div id="programmerCalculator" class="hidden">
|
| 216 |
<div class="result-display">
|
|
|
|
| 255 |
</div>
|
| 256 |
<div class="mt-2 text-center font-bold" id="bitwiseResult">Result: 0</div>
|
| 257 |
</div>
|
| 258 |
+
<div class="mb-4">
|
| 259 |
+
<label class="block text-gray-700 mb-2">Advanced Operations</label>
|
| 260 |
+
<div class="grid grid-cols-2 md:grid-cols-4 gap-2 mt-2">
|
| 261 |
+
<button class="calculator-btn bg-gray-700 hover:bg-gray-600 text-white font-bold py-2 rounded-xl" onclick="shiftBits('left')">Shift Left</button>
|
| 262 |
+
<button class="calculator-btn bg-gray-700 hover:bg-gray-600 text-white font-bold py-2 rounded-xl" onclick="shiftBits('right')">Shift Right</button>
|
| 263 |
+
<button class="calculator-btn bg-gray-700 hover:bg-gray-600 text-white font-bold py-2 rounded-xl" onclick="rotateBits('left')">Rotate Left</button>
|
| 264 |
+
<button class="calculator-btn bg-gray-700 hover:bg-gray-600 text-white font-bold py-2 rounded-xl" onclick="rotateBits('right')">Rotate Right</button>
|
| 265 |
+
</div>
|
| 266 |
+
</div>
|
| 267 |
+
<div class="mb-4">
|
| 268 |
+
<label class="block text-gray-700 mb-2">Logic Operations</label>
|
| 269 |
+
<div class="grid grid-cols-2 md:grid-cols-3 gap-2 mt-2">
|
| 270 |
+
<button class="calculator-btn bg-gray-700 hover:bg-gray-600 text-white font-bold py-2 rounded-xl" onclick="logicOperation('nand')">NAND</button>
|
| 271 |
+
<button class="calculator-btn bg-gray-700 hover:bg-gray-600 text-white font-bold py-2 rounded-xl" onclick="logicOperation('nor')">NOR</button>
|
| 272 |
+
<button class="calculator-btn bg-gray-700 hover:bg-gray-600 text-white font-bold py-2 rounded-xl" onclick="logicOperation('xnor')">XNOR</button>
|
| 273 |
+
</div>
|
| 274 |
+
</div>
|
| 275 |
</div>
|
| 276 |
</div>
|
|
|
|
| 277 |
<!-- Financial Calculator -->
|
| 278 |
<div id="financialCalculator" class="hidden">
|
| 279 |
<div class="result-display">
|
|
|
|
| 302 |
</div>
|
| 303 |
</div>
|
| 304 |
<div class="grid grid-cols-2 gap-4 mb-4">
|
| 305 |
+
<button class="calculator-btn bg-primary hover:bg-indigo-600 text-white font-bold py-3 rounded-xl" onclick="calculateCompoundInterest()">Calculate Compound Interest</button>
|
| 306 |
<button class="calculator-btn bg-gray-700 hover:bg-gray-600 text-white font-bold py-3 rounded-xl" onclick="clearFinancial()">Clear</button>
|
| 307 |
</div>
|
| 308 |
+
<div class="bg-gray-100 rounded-xl p-4 mb-4">
|
| 309 |
<div class="flex justify-between mb-2">
|
| 310 |
<span>Future Value:</span>
|
| 311 |
<span id="futureValue" class="font-bold">$1,280.08</span>
|
|
|
|
| 319 |
<span id="apyRate" class="font-bold">5.12%</span>
|
| 320 |
</div>
|
| 321 |
</div>
|
| 322 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
|
| 323 |
+
<div>
|
| 324 |
+
<label class="block text-gray-700 mb-2">Loan Amount ($)</label>
|
| 325 |
+
<input type="number" id="loanAmount" class="w-full p-3 rounded-lg bg-gray-100 text-black" placeholder="Loan amount" value="10000">
|
| 326 |
+
</div>
|
| 327 |
+
<div>
|
| 328 |
+
<label class="block text-gray-700 mb-2">Annual Interest Rate (%)</label>
|
| 329 |
+
<input type="number" id="loanInterestRate" class="w-full p-3 rounded-lg bg-gray-100 text-black" placeholder="Annual interest rate" value="6">
|
| 330 |
+
</div>
|
| 331 |
+
<div>
|
| 332 |
+
<label class="block text-gray-700 mb-2">Loan Term (Years)</label>
|
| 333 |
+
<input type="number" id="loanTerm" class="w-full p-3 rounded-lg bg-gray-100 text-black" placeholder="Loan term" value="5">
|
| 334 |
+
</div>
|
| 335 |
+
<div>
|
| 336 |
+
<label class="block text-gray-700 mb-2">Payments Per Year</label>
|
| 337 |
+
<input type="number" id="paymentsPerYear" class="w-full p-3 rounded-lg bg-gray-100 text-black" placeholder="Payments per year" value="12">
|
| 338 |
+
</div>
|
| 339 |
+
</div>
|
| 340 |
+
<div class="grid grid-cols-2 gap-4 mb-4">
|
| 341 |
+
<button class="calculator-btn bg-primary hover:bg-indigo-600 text-white font-bold py-3 rounded-xl" onclick="calculateLoanPayment()">Calculate Loan Payment</button>
|
| 342 |
+
<button class="calculator-btn bg-gray-700 hover:bg-gray-600 text-white font-bold py-3 rounded-xl" onclick="clearLoan()">Clear Loan</button>
|
| 343 |
+
</div>
|
| 344 |
+
<div class="bg-gray-100 rounded-xl p-4">
|
| 345 |
+
<div class="flex justify-between mb-2">
|
| 346 |
+
<span>Monthly Payment:</span>
|
| 347 |
+
<span id="monthlyPayment" class="font-bold">$193.33</span>
|
| 348 |
+
</div>
|
| 349 |
+
<div class="flex justify-between mb-2">
|
| 350 |
+
<span>Total Payment:</span>
|
| 351 |
+
<span id="totalPayment" class="font-bold">$11,599.80</span>
|
| 352 |
+
</div>
|
| 353 |
+
<div class="flex justify-between">
|
| 354 |
+
<span>Total Interest:</span>
|
| 355 |
+
<span id="loanTotalInterest" class="font-bold">$1,599.80</span>
|
| 356 |
+
</div>
|
| 357 |
+
</div>
|
| 358 |
</div>
|
| 359 |
</div>
|
| 360 |
</div>
|
|
|
|
| 959 |
}
|
| 960 |
document.getElementById('matrixResult').innerHTML = 'Result will appear here';
|
| 961 |
}
|
|
|
|
| 962 |
// Statistics functions
|
| 963 |
function calculateStatistics() {
|
| 964 |
const dataInput = document.getElementById('dataSet').value;
|
|
|
|
| 975 |
return;
|
| 976 |
}
|
| 977 |
|
| 978 |
+
// Calculate basic statistics
|
| 979 |
const count = dataArray.length;
|
| 980 |
const sum = dataArray.reduce((acc, num) => acc + num, 0);
|
| 981 |
const mean = sum / count;
|
|
|
|
| 1014 |
const variance = squaredDifferences.reduce((acc, val) => acc + val, 0) / count;
|
| 1015 |
const stdDev = Math.sqrt(variance);
|
| 1016 |
|
| 1017 |
+
// Quartiles
|
| 1018 |
+
const q1Index = Math.floor(0.25 * (count - 1));
|
| 1019 |
+
const q3Index = Math.floor(0.75 * (count - 1));
|
| 1020 |
+
const q1 = sortedArray[q1Index];
|
| 1021 |
+
const q3 = sortedArray[q3Index];
|
| 1022 |
+
const iqr = q3 - q1;
|
| 1023 |
+
|
| 1024 |
+
// Skewness
|
| 1025 |
+
const skewness = (count * squaredDifferences.reduce((acc, val, i) =>
|
| 1026 |
+
acc + Math.pow(dataArray[i] - mean, 3), 0)) /
|
| 1027 |
+
((count - 1) * (count - 2) * Math.pow(stdDev, 3));
|
| 1028 |
+
|
| 1029 |
// Update UI
|
| 1030 |
document.getElementById('statCount').textContent = count;
|
| 1031 |
document.getElementById('statSum').textContent = sum.toFixed(2);
|
|
|
|
| 1035 |
document.getElementById('statRange').textContent = range.toFixed(2);
|
| 1036 |
document.getElementById('statVariance').textContent = variance.toFixed(4);
|
| 1037 |
document.getElementById('statStdDev').textContent = stdDev.toFixed(4);
|
| 1038 |
+
document.getElementById('statQ1').textContent = q1.toFixed(4);
|
| 1039 |
+
document.getElementById('statQ3').textContent = q3.toFixed(4);
|
| 1040 |
+
document.getElementById('statIQR').textContent = iqr.toFixed(4);
|
| 1041 |
+
document.getElementById('statSkewness').textContent = skewness.toFixed(4);
|
| 1042 |
+
|
| 1043 |
+
// Update chart
|
| 1044 |
+
updateStatisticsChart(sortedArray);
|
| 1045 |
} catch (error) {
|
| 1046 |
alert("Error calculating statistics: " + error.message);
|
| 1047 |
}
|
| 1048 |
}
|
| 1049 |
|
| 1050 |
+
function updateStatisticsChart(data) {
|
| 1051 |
+
const ctx = document.getElementById('statisticsChart').getContext('2d');
|
| 1052 |
+
|
| 1053 |
+
// Destroy existing chart if it exists
|
| 1054 |
+
if (window.statisticsChart) {
|
| 1055 |
+
window.statisticsChart.destroy();
|
| 1056 |
+
}
|
| 1057 |
+
|
| 1058 |
+
// Create histogram data
|
| 1059 |
+
const min = Math.min(...data);
|
| 1060 |
+
const max = Math.max(...data);
|
| 1061 |
+
const binCount = Math.min(10, data.length);
|
| 1062 |
+
const binWidth = (max - min) / binCount;
|
| 1063 |
+
|
| 1064 |
+
const bins = Array(binCount).fill(0);
|
| 1065 |
+
const labels = [];
|
| 1066 |
+
|
| 1067 |
+
for (let i = 0; i < binCount; i++) {
|
| 1068 |
+
labels.push(`${(min + i * binWidth).toFixed(1)} - ${(min + (i + 1) * binWidth).toFixed(1)}`);
|
| 1069 |
+
}
|
| 1070 |
+
|
| 1071 |
+
data.forEach(value => {
|
| 1072 |
+
const binIndex = Math.min(Math.floor((value - min) / binWidth), binCount - 1);
|
| 1073 |
+
bins[binIndex]++;
|
| 1074 |
+
});
|
| 1075 |
+
|
| 1076 |
+
window.statisticsChart = new Chart(ctx, {
|
| 1077 |
+
type: 'bar',
|
| 1078 |
+
data: {
|
| 1079 |
+
labels: labels,
|
| 1080 |
+
datasets: [{
|
| 1081 |
+
label: 'Frequency',
|
| 1082 |
+
data: bins,
|
| 1083 |
+
backgroundColor: 'rgba(99, 102, 241, 0.7)',
|
| 1084 |
+
borderColor: 'rgba(99, 102, 241, 1)',
|
| 1085 |
+
borderWidth: 1
|
| 1086 |
+
}]
|
| 1087 |
+
},
|
| 1088 |
+
options: {
|
| 1089 |
+
responsive: true,
|
| 1090 |
+
maintainAspectRatio: false,
|
| 1091 |
+
scales: {
|
| 1092 |
+
y: {
|
| 1093 |
+
beginAtZero: true,
|
| 1094 |
+
title: {
|
| 1095 |
+
display: true,
|
| 1096 |
+
text: 'Frequency'
|
| 1097 |
+
}
|
| 1098 |
+
},
|
| 1099 |
+
x: {
|
| 1100 |
+
title: {
|
| 1101 |
+
display: true,
|
| 1102 |
+
text: 'Value Range'
|
| 1103 |
+
}
|
| 1104 |
+
}
|
| 1105 |
+
}
|
| 1106 |
+
}
|
| 1107 |
+
});
|
| 1108 |
+
}
|
| 1109 |
+
|
| 1110 |
function clearStatistics() {
|
| 1111 |
document.getElementById('dataSet').value = '';
|
| 1112 |
document.getElementById('statCount').textContent = '0';
|
|
|
|
| 1117 |
document.getElementById('statRange').textContent = '0';
|
| 1118 |
document.getElementById('statVariance').textContent = '0';
|
| 1119 |
document.getElementById('statStdDev').textContent = '0';
|
| 1120 |
+
document.getElementById('statQ1').textContent = '0';
|
| 1121 |
+
document.getElementById('statQ3').textContent = '0';
|
| 1122 |
+
document.getElementById('statIQR').textContent = '0';
|
| 1123 |
+
document.getElementById('statSkewness').textContent = '0';
|
| 1124 |
+
|
| 1125 |
+
// Clear chart
|
| 1126 |
+
const ctx = document.getElementById('statisticsChart').getContext('2d');
|
| 1127 |
+
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
| 1128 |
}
|
| 1129 |
+
// Programmer functions
|
|
|
|
| 1130 |
function convertNumberSystems() {
|
| 1131 |
const decInput = document.getElementById('decInput');
|
| 1132 |
const binInput = document.getElementById('binInput');
|
|
|
|
| 1160 |
// Invalid input - do nothing
|
| 1161 |
}
|
| 1162 |
}
|
|
|
|
| 1163 |
function performBitwise(operation) {
|
| 1164 |
const num1 = parseInt(document.getElementById('bitNum1').value) || 0;
|
| 1165 |
const num2 = parseInt(document.getElementById('bitNum2').value) || 0;
|
|
|
|
| 1185 |
document.getElementById('bitwiseResult').textContent = `Result: ${result} (0b${result.toString(2)})`;
|
| 1186 |
}
|
| 1187 |
|
| 1188 |
+
function shiftBits(direction) {
|
| 1189 |
+
const num1 = parseInt(document.getElementById('bitNum1').value) || 0;
|
| 1190 |
+
const positions = parseInt(document.getElementById('bitNum2').value) || 1;
|
| 1191 |
+
let result;
|
| 1192 |
+
|
| 1193 |
+
if (direction === 'left') {
|
| 1194 |
+
result = num1 << positions;
|
| 1195 |
+
} else {
|
| 1196 |
+
result = num1 >> positions;
|
| 1197 |
+
}
|
| 1198 |
+
|
| 1199 |
+
document.getElementById('bitwiseResult').textContent = `Result: ${result} (0b${result.toString(2)})`;
|
| 1200 |
+
}
|
| 1201 |
+
|
| 1202 |
+
function rotateBits(direction) {
|
| 1203 |
+
const num1 = parseInt(document.getElementById('bitNum1').value) || 0;
|
| 1204 |
+
const positions = parseInt(document.getElementById('bitNum2').value) || 1;
|
| 1205 |
+
let result;
|
| 1206 |
+
|
| 1207 |
+
// 32-bit rotation
|
| 1208 |
+
if (direction === 'left') {
|
| 1209 |
+
result = (num1 << positions) | (num1 >>> (32 - positions));
|
| 1210 |
+
} else {
|
| 1211 |
+
result = (num1 >>> positions) | (num1 << (32 - positions));
|
| 1212 |
+
}
|
| 1213 |
+
|
| 1214 |
+
document.getElementById('bitwiseResult').textContent = `Result: ${result} (0b${result.toString(2)})`;
|
| 1215 |
+
}
|
| 1216 |
+
|
| 1217 |
+
function logicOperation(operation) {
|
| 1218 |
+
const num1 = parseInt(document.getElementById('bitNum1').value) || 0;
|
| 1219 |
+
const num2 = parseInt(document.getElementById('bitNum2').value) || 0;
|
| 1220 |
+
let result;
|
| 1221 |
+
|
| 1222 |
+
switch(operation) {
|
| 1223 |
+
case 'nand':
|
| 1224 |
+
result = ~(num1 & num2);
|
| 1225 |
+
break;
|
| 1226 |
+
case 'nor':
|
| 1227 |
+
result = ~(num1 | num2);
|
| 1228 |
+
break;
|
| 1229 |
+
case 'xnor':
|
| 1230 |
+
result = ~(num1 ^ num2);
|
| 1231 |
+
break;
|
| 1232 |
+
default:
|
| 1233 |
+
result = 0;
|
| 1234 |
+
}
|
| 1235 |
+
|
| 1236 |
+
document.getElementById('bitwiseResult').textContent = `Result: ${result} (0b${result.toString(2)})`;
|
| 1237 |
+
}
|
| 1238 |
// Financial functions
|
| 1239 |
function calculateCompoundInterest() {
|
| 1240 |
const principal = parseFloat(document.getElementById('principal').value) || 0;
|
|
|
|
| 1255 |
document.getElementById('apyRate').textContent = `${apy.toFixed(2)}%`;
|
| 1256 |
}
|
| 1257 |
|
| 1258 |
+
function calculateLoanPayment() {
|
| 1259 |
+
const loanAmount = parseFloat(document.getElementById('loanAmount').value) || 0;
|
| 1260 |
+
const annualInterestRate = (parseFloat(document.getElementById('loanInterestRate').value) || 0) / 100;
|
| 1261 |
+
const loanTerm = parseFloat(document.getElementById('loanTerm').value) || 0;
|
| 1262 |
+
const paymentsPerYear = parseInt(document.getElementById('paymentsPerYear').value) || 12;
|
| 1263 |
+
|
| 1264 |
+
const monthlyRate = annualInterestRate / paymentsPerYear;
|
| 1265 |
+
const totalPayments = loanTerm * paymentsPerYear;
|
| 1266 |
+
|
| 1267 |
+
// Monthly payment calculation
|
| 1268 |
+
const monthlyPayment = (loanAmount * monthlyRate) / (1 - Math.pow(1 + monthlyRate, -totalPayments));
|
| 1269 |
+
const totalPayment = monthlyPayment * totalPayments;
|
| 1270 |
+
const totalInterest = totalPayment - loanAmount;
|
| 1271 |
+
|
| 1272 |
+
// Update UI
|
| 1273 |
+
document.getElementById('monthlyPayment').textContent = `${monthlyPayment.toFixed(2)}`;
|
| 1274 |
+
document.getElementById('totalPayment').textContent = `${totalPayment.toFixed(2)}`;
|
| 1275 |
+
document.getElementById('loanTotalInterest').textContent = `${totalInterest.toFixed(2)}`;
|
| 1276 |
+
}
|
| 1277 |
+
|
| 1278 |
function clearFinancial() {
|
| 1279 |
document.getElementById('principal').value = '1000';
|
| 1280 |
document.getElementById('interestRate').value = '5';
|
|
|
|
| 1285 |
document.getElementById('apyRate').textContent = '5.12%';
|
| 1286 |
}
|
| 1287 |
|
| 1288 |
+
function clearLoan() {
|
| 1289 |
+
document.getElementById('loanAmount').value = '10000';
|
| 1290 |
+
document.getElementById('loanInterestRate').value = '6';
|
| 1291 |
+
document.getElementById('loanTerm').value = '5';
|
| 1292 |
+
document.getElementById('paymentsPerYear').value = '12';
|
| 1293 |
+
document.getElementById('monthlyPayment').textContent = '$193.33';
|
| 1294 |
+
document.getElementById('totalPayment').textContent = '$11,599.80';
|
| 1295 |
+
document.getElementById('loanTotalInterest').textContent = '$1,599.80';
|
| 1296 |
+
}
|
| 1297 |
+
// Calculus functions
|
| 1298 |
function initializeChart() {
|
| 1299 |
const ctx = document.getElementById('functionChart').getContext('2d');
|
| 1300 |
functionChart = new Chart(ctx, {
|