diff --git a/Bayes Theorem Calculator/icon.png b/Bayes Theorem Calculator/icon.png new file mode 100644 index 00000000..6c2d962e Binary files /dev/null and b/Bayes Theorem Calculator/icon.png differ diff --git a/Bayes Theorem Calculator/manifest.json b/Bayes Theorem Calculator/manifest.json new file mode 100644 index 00000000..cc273a3e --- /dev/null +++ b/Bayes Theorem Calculator/manifest.json @@ -0,0 +1,16 @@ +{ + "manifest_version": 3, + "name": "Bayes theorem Calculator", + "version": "1.0", + "description": "Bayes theorem calculator.", + "action": { + "default_popup": "popup.html", + "default_icon": { + "128": "icon.png" + } + }, + "icons": { + "128": "icon.png" + }, + "permissions": ["activeTab"] +} \ No newline at end of file diff --git a/Bayes Theorem Calculator/popup.html b/Bayes Theorem Calculator/popup.html new file mode 100644 index 00000000..227251dc --- /dev/null +++ b/Bayes Theorem Calculator/popup.html @@ -0,0 +1,33 @@ + + + + + + + + Bayes Theorem Calculator + + + +
+

Bayes Theorem Calculator

+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + + + + \ No newline at end of file diff --git a/Bayes Theorem Calculator/script.js b/Bayes Theorem Calculator/script.js new file mode 100644 index 00000000..1cfd2639 --- /dev/null +++ b/Bayes Theorem Calculator/script.js @@ -0,0 +1,27 @@ +document.addEventListener('DOMContentLoaded', function() { + document.getElementById('calculateButton').addEventListener('click', calculateBayesianTheorem); +}); + +function calculateBayesianTheorem() { + // Get values from input fields + var probabilityA = parseFloat(document.getElementById("probabilityA").value); + var probabilityBGivenA = parseFloat(document.getElementById("probabilityBGivenA").value); + var probabilityNotA = parseFloat(document.getElementById("probabilityNotA").value); + + // Validate input + if ( + isNaN(probabilityA) || isNaN(probabilityBGivenA) || isNaN(probabilityNotA) || + probabilityA < 0 || probabilityBGivenA < 0 || probabilityNotA < 0 || + probabilityA > 1 || probabilityBGivenA > 1 || probabilityNotA > 1 + ) { + alert("Please enter valid probabilities between 0 and 1."); + return; + } + + // Calculate Bayesian Theorem + var probabilityB = (probabilityBGivenA * probabilityA) + ((1 - probabilityA) * probabilityNotA); + var probabilityAGivenB = (probabilityBGivenA * probabilityA) / probabilityB; + + // Display the result + document.getElementById("result").innerHTML = "P(A|B) ≈ " + probabilityAGivenB.toFixed(4); +} diff --git a/Bayes Theorem Calculator/style.css b/Bayes Theorem Calculator/style.css new file mode 100644 index 00000000..79c8fcb1 --- /dev/null +++ b/Bayes Theorem Calculator/style.css @@ -0,0 +1,84 @@ +body { + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + background: linear-gradient(to bottom right, #3494e6, #ec6ead); + margin: 0; + display: flex; + align-items: center; + justify-content: center; + height: 100vh; + width: 500px; +} + +.calculator-container { + background-color: #fff; + padding: 30px; + border-radius: 12px; + box-shadow: 0 0 20px rgba(0, 0, 0, 0.2); + text-align: center; + animation: fadeInUp 0.8s ease-out; +} + +button { + background-color: #4caf50; + color: #fff; + padding: 15px 30px; + border: none; + border-radius: 6px; + cursor: pointer; + font-size: 18px; + margin-top: 20px; + transition: background-color 0.3s ease, transform 0.2s ease-out; +} + +button:hover { + background-color: #45a049; + transform: scale(1.05); +} + +input { + padding: 15px; + margin: 15px 0; + width: 80%; + box-sizing: border-box; + font-size: 18px; + border: 1px solid #ccc; + border-radius: 6px; + transition: border-color 0.3s ease, transform 0.2s ease-out; +} + +input:focus { + outline: none; + border-color: #4caf50; + transform: scale(1.02); +} + +#result { + font-size: 20px; + font-weight: bold; + color: #333; + margin-top: 20px; + animation: fadeIn 1s ease-out; +} + +/* Animations */ +@keyframes fadeInUp { + from { + opacity: 0; + transform: translateY(20px); + } + + to { + opacity: 1; + transform: translateY(0); + } +} + +@keyframes fadeIn { + from { + opacity: 0; + } + + to { + opacity: 1; + } +} \ No newline at end of file