{"id":249,"date":"2026-03-23T22:27:54","date_gmt":"2026-03-23T14:27:54","guid":{"rendered":"https:\/\/yoyodyne.com.au\/?page_id=249"},"modified":"2026-03-25T07:31:49","modified_gmt":"2026-03-24T23:31:49","slug":"sample-quota-calculator","status":"publish","type":"page","link":"https:\/\/yoyodyne.com.au\/index.php\/sample-quota-calculator\/","title":{"rendered":"Sample Quota calculator"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Occupational Hygiene Sample Quota Calculator<\/title>\n    <!-- Tailwind CSS for styling -->\n    <script src=\"https:\/\/cdn.tailwindcss.com\"><\/script>\n    <!-- MathJax for LaTeX formulas -->\n    <script id=\"MathJax-script\" async src=\"https:\/\/cdn.jsdelivr.net\/npm\/mathjax@3\/es5\/tex-mml-chtml.js\"><\/script>\n    <style>\n        \/* Scoped styles to prevent WordPress interference *\/\n        .ydn-calculator-wrapper .ydn-result-card {\n            transition: all 0.3s ease;\n        }\n        .ydn-calculator-wrapper input[type=number]::-webkit-inner-spin-button, \n        .ydn-calculator-wrapper input[type=number]::-webkit-outer-spin-button { \n            -webkit-appearance: none; margin: 0; \n        }\n    <\/style>\n<\/head>\n<body class=\"bg-gray-50 p-4\">\n\n    <div class=\"ydn-calculator-wrapper max-w-2xl mx-auto bg-white rounded-2xl shadow-xl overflow-hidden border border-gray-100 text-left\">\n        <!-- Header -->\n        <div class=\"bg-slate-800 p-6 text-white text-center\">\n            <h2 class=\"text-2xl font-bold m-0 text-white\">SEG Sample Quota Calculator<\/h2>\n            <p class=\"text-slate-300 text-sm mt-1\">Based on Hypergeometric Distribution<\/p>\n        <\/div>\n\n        <!-- Tool Content -->\n        <div class=\"p-6 space-y-6\">\n            \n            <!-- Input Grid -->\n            <div class=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\n                <div>\n                    <label class=\"block text-sm font-semibold text-gray-700 mb-1\">Population Size ($N$)<\/label>\n                    <input type=\"number\" id=\"ydn-popN\" value=\"18\" class=\"w-full px-4 py-2 border rounded-lg focus:ring-2 focus:ring-slate-500 outline-none\">\n                <\/div>\n                <div>\n                    <label class=\"block text-sm font-semibold text-gray-700 mb-1\">Target Group % (e.g., Top 10%)<\/label>\n                    <div class=\"flex\">\n                        <input type=\"number\" id=\"ydn-targetPct\" value=\"10\" class=\"w-full px-4 py-2 border rounded-l-lg focus:ring-2 focus:ring-slate-500 outline-none\">\n                        <span class=\"inline-flex items-center px-3 rounded-r-lg border border-l-0 bg-gray-100 text-gray-500\">%<\/span>\n                    <\/div>\n                <\/div>\n                <div>\n                    <label class=\"block text-sm font-semibold text-gray-700 mb-1\">Number of Samples ($n$)<\/label>\n                    <input type=\"number\" id=\"ydn-sampleN\" value=\"12\" class=\"w-full px-4 py-2 border rounded-lg focus:ring-2 focus:ring-slate-500 outline-none\">\n                <\/div>\n                <div class=\"flex flex-col justify-end\">\n                    <button onclick=\"ydnCalculate()\" class=\"w-full bg-slate-700 hover:bg-slate-800 text-white font-bold py-2 rounded-lg transition duration-200\">\n                        Calculate Confidence\n                    <\/button>\n                <\/div>\n            <\/div>\n\n            <!-- Calculated Inputs Display -->\n            <div id=\"ydn-derivedInputs\" class=\"bg-slate-50 p-4 rounded-xl text-sm text-gray-600 grid grid-cols-2 gap-2 border border-slate-100\">\n                <div>Target Workers ($N_0$): <span id=\"ydn-valN0\" class=\"font-bold text-slate-800\">2<\/span><\/div>\n                <div>Non-Target ($N-N_0$): <span id=\"ydn-valNonTarget\" class=\"font-bold text-slate-800\">16<\/span><\/div>\n            <\/div>\n\n            <!-- Results Section -->\n            <div id=\"ydn-resultArea\" class=\"ydn-result-card p-6 rounded-xl text-center space-y-4 border-2 border-transparent\">\n                <div class=\"text-gray-500 text-sm font-medium uppercase tracking-wider\">Statistical Confidence Level<\/div>\n                <div id=\"ydn-confidenceVal\" class=\"text-5xl font-black text-slate-800\">0%<\/div>\n                <div id=\"ydn-riskVal\" class=\"text-sm text-gray-500\">Probability of missing target: 0%<\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <script>\n        \/**\n         * Calculate combinations nCr\n         *\/\n        function ydnCombinations(n, r) {\n            if (r < 0 || r > n) return 0;\n            if (r === 0 || r === n) return 1;\n            if (r > n \/ 2) r = n - r;\n            \n            let res = 1;\n            for (let i = 1; i <= r; i++) {\n                res = res * (n - i + 1) \/ i;\n            }\n            return res;\n        }\n\n        \/**\n         * Main calculation logic triggered by the button\n         *\/\n        function ydnCalculate() {\n            const N = parseInt(document.getElementById('ydn-popN').value);\n            const targetPct = parseFloat(document.getElementById('ydn-targetPct').value) \/ 100;\n            const n = parseInt(document.getElementById('ydn-sampleN').value);\n            \n            \/\/ N0 is the number of workers in the high-risk group\n            let N0 = Math.max(1, Math.round(N * targetPct));\n            const nonTarget = N - N0;\n\n            \/\/ Update derived values in UI\n            document.getElementById('ydn-valN0').innerText = N0;\n            document.getElementById('ydn-valNonTarget').innerText = nonTarget;\n\n            const resultArea = document.getElementById('ydn-resultArea');\n            const confidenceVal = document.getElementById('ydn-confidenceVal');\n            \n            \/\/ Error handling for invalid sample sizes\n            if (n > N) {\n                confidenceVal.innerText = \"N\/A\";\n                document.getElementById('ydn-riskVal').innerText = \"Sample size cannot exceed population.\";\n                resultArea.className = \"ydn-result-card p-6 rounded-xl text-center space-y-4 border-2 border-red-200 bg-red-50 text-red-800\";\n                return;\n            }\n\n            \/\/ Probability calculation based on your mentoring notes\n            const combNonTarget = ydnCombinations(nonTarget, n);\n            const combTotal = ydnCombinations(N, n);\n            \n            const probMissing = combNonTarget \/ combTotal;\n            const confidence = (1 - probMissing) * 100;\n\n            \/\/ Update primary results\n            confidenceVal.innerText = confidence.toFixed(1) + \"%\";\n            document.getElementById('ydn-riskVal').innerText = \"Risk of missing highest exposed group: \" + (probMissing * 100).toFixed(1) + \"%\";\n            \n            \/\/ Dynamic visual feedback based on hygiene confidence thresholds\n            if (confidence >= 95) {\n                resultArea.className = \"ydn-result-card p-6 rounded-xl text-center space-y-4 border-2 border-green-500 bg-green-50\";\n                confidenceVal.className = \"text-5xl font-black text-green-700\";\n            } else if (confidence >= 80) {\n                resultArea.className = \"ydn-result-card p-6 rounded-xl text-center space-y-4 border-2 border-blue-400 bg-blue-50\";\n                confidenceVal.className = \"text-5xl font-black text-blue-700\";\n            } else {\n                resultArea.className = \"ydn-result-card p-6 rounded-xl text-center space-y-4 border-2 border-amber-300 bg-amber-50\";\n                confidenceVal.className = \"text-5xl font-black text-amber-700\";\n            }\n        }\n\n        \/\/ Run calculation on load to show default values\n        window.onload = function() {\n            ydnCalculate();\n        };\n    <\/script>\n\n<\/body>\n<\/html>\n\n\n<div class=\"markdown-block\"><p>$$Formula: P(r=0) = \\frac{(N-N_0)!}{(N-N_0-n)!} \\times \\frac{(N-n)!}{N!} $$<\/p>\n\n<p>$$ Confidence = 1 &#8211; P(r=0)$$<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Occupational Hygiene Sample Quota Calculator SEG Sample Quota Calculator Based on Hypergeometric Distribution Population Size ($N$) Target Group % (e.g., Top 10%) % Number of Samples ($n$) Calculate Confidence Target Workers ($N_0$): 2 Non-Target ($N-N_0$): 16 Statistical Confidence Level 0% Probability of missing target: 0%<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-249","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/yoyodyne.com.au\/index.php\/wp-json\/wp\/v2\/pages\/249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yoyodyne.com.au\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/yoyodyne.com.au\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/yoyodyne.com.au\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yoyodyne.com.au\/index.php\/wp-json\/wp\/v2\/comments?post=249"}],"version-history":[{"count":11,"href":"https:\/\/yoyodyne.com.au\/index.php\/wp-json\/wp\/v2\/pages\/249\/revisions"}],"predecessor-version":[{"id":272,"href":"https:\/\/yoyodyne.com.au\/index.php\/wp-json\/wp\/v2\/pages\/249\/revisions\/272"}],"wp:attachment":[{"href":"https:\/\/yoyodyne.com.au\/index.php\/wp-json\/wp\/v2\/media?parent=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}