[{"data":1,"prerenderedAt":41},["ShallowReactive",2],{"4596248":3},{"type_of":4,"id":5,"title":6,"description":7,"readable_publish_date":8,"slug":9,"path":10,"url":11,"comments_count":12,"public_reactions_count":13,"collection_id":14,"published_timestamp":15,"language":16,"subforem_id":17,"ai_disclosure_level":18,"ai_disclosure_label":19,"positive_reactions_count":13,"cover_image":14,"social_image":20,"canonical_url":11,"created_at":15,"edited_at":14,"crossposted_at":14,"published_at":15,"last_comment_at":15,"reading_time_minutes":21,"tag_list":22,"tags":23,"body_html":27,"body_markdown":28,"user":29,"organization":36},"article",4596248,"Why comparing insurance deductibles needs shared random medical-spend paths","The hard part of comparing a high-deductible, low-premium plan with a low-deductible plan is not...","Sep 7","why-comparing-insurance-deductibles-needs-shared-random-medical-spend-paths-4lc1","/begoodtool/why-comparing-insurance-deductibles-needs-shared-random-medical-spend-paths-4lc1","https://dev.to/begoodtool/why-comparing-insurance-deductibles-needs-shared-random-medical-spend-paths-4lc1",0,6,null,"2026-09-07T13:00:03Z","en",1,"not_disclosed","Not Disclosed","https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbsggllnjajgsezx54f5k.png",4,"javascript, vue, algorithms",[24,25,26],"javascript","vue","algorithms","\u003Cp>The hard part of comparing a high-deductible, low-premium plan with a low-deductible plan is not adding two premiums. Medical spending varies, and a fair comparison should expose both ordinary and expensive years. I built this simulator so both plans see the same generated spending path; otherwise random noise can make one plan look better simply because it received easier years. The useful audience is someone who can read a spreadsheet or a little JavaScript and wants to reason about uncertainty without mistaking a simulation for an insurer's forecast.\u003C/p>\n\n\u003Ch2>\n  \u003Ca name=\"generate-one-annual-spend-then-apply-both-plan-rules\" href=\"#generate-one-annual-spend-then-apply-both-plan-rules\">\n  \u003C/a>\n  Generate one annual spend, then apply both plan rules\n\u003C/h2>\n\n\u003Cp>Annual spending uses a log-normal-style transformation. First, \u003Ccode>randomStandardNormal()\u003C/code> makes a normal deviate with the Box-Muller transform. Then volatility becomes \u003Ccode>sigma\u003C/code>, and the result is exponentiated and clamped:\u003Cbr>\n\u003C/p>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight javascript\">\u003Ccode>\u003Cspan class=\"kd\">function\u003C/span> \u003Cspan class=\"nf\">randomStandardNormal\u003C/span>\u003Cspan class=\"p\">()\u003C/span> \u003Cspan class=\"p\">{\u003C/span>\n  \u003Cspan class=\"kd\">let\u003C/span> \u003Cspan class=\"nx\">u1\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">random\u003C/span>\u003Cspan class=\"p\">();\u003C/span>\n  \u003Cspan class=\"kd\">const\u003C/span> \u003Cspan class=\"nx\">u2\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">random\u003C/span>\u003Cspan class=\"p\">();\u003C/span>\n  \u003Cspan class=\"k\">if \u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">u1\u003C/span> \u003Cspan class=\"o\">&lt;=\u003C/span> \u003Cspan class=\"mi\">1\u003C/span>\u003Cspan class=\"nx\">e\u003C/span>\u003Cspan class=\"o\">-\u003C/span>\u003Cspan class=\"mi\">12\u003C/span>\u003Cspan class=\"p\">)\u003C/span> \u003Cspan class=\"nx\">u1\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"mi\">1\u003C/span>\u003Cspan class=\"nx\">e\u003C/span>\u003Cspan class=\"o\">-\u003C/span>\u003Cspan class=\"mi\">12\u003C/span>\u003Cspan class=\"p\">;\u003C/span>\n  \u003Cspan class=\"k\">return\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">sqrt\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"o\">-\u003C/span>\u003Cspan class=\"mi\">2\u003C/span> \u003Cspan class=\"o\">*\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">log\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">u1\u003C/span>\u003Cspan class=\"p\">))\u003C/span> \u003Cspan class=\"o\">*\u003C/span>\n    \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">cos\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"mi\">2\u003C/span> \u003Cspan class=\"o\">*\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nx\">PI\u003C/span> \u003Cspan class=\"o\">*\u003C/span> \u003Cspan class=\"nx\">u2\u003C/span>\u003Cspan class=\"p\">);\u003C/span>\n\u003Cspan class=\"p\">}\u003C/span>\n\n\u003Cspan class=\"kd\">function\u003C/span> \u003Cspan class=\"nf\">annualMedicalSpend\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">avg\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">volatilityPct\u003C/span>\u003Cspan class=\"p\">)\u003C/span> \u003Cspan class=\"p\">{\u003C/span>\n  \u003Cspan class=\"kd\">const\u003C/span> \u003Cspan class=\"nx\">sigma\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">max\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">volatilityPct\u003C/span> \u003Cspan class=\"o\">||\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">)\u003C/span> \u003Cspan class=\"o\">/\u003C/span> \u003Cspan class=\"mi\">100\u003C/span>\u003Cspan class=\"p\">;\u003C/span>\n  \u003Cspan class=\"k\">if \u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">sigma\u003C/span> \u003Cspan class=\"o\">===\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">)\u003C/span> \u003Cspan class=\"k\">return\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">max\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">avg\u003C/span> \u003Cspan class=\"o\">||\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">);\u003C/span>\n  \u003Cspan class=\"kd\">const\u003C/span> \u003Cspan class=\"nx\">z\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nf\">randomStandardNormal\u003C/span>\u003Cspan class=\"p\">();\u003C/span>\n  \u003Cspan class=\"k\">return\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">max\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">avg\u003C/span> \u003Cspan class=\"o\">||\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">)\u003C/span> \u003Cspan class=\"o\">*\u003C/span>\n    \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">exp\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"o\">-\u003C/span>\u003Cspan class=\"mf\">0.5\u003C/span> \u003Cspan class=\"o\">*\u003C/span> \u003Cspan class=\"nx\">sigma\u003C/span> \u003Cspan class=\"o\">*\u003C/span> \u003Cspan class=\"nx\">sigma\u003C/span> \u003Cspan class=\"o\">+\u003C/span> \u003Cspan class=\"nx\">sigma\u003C/span> \u003Cspan class=\"o\">*\u003C/span> \u003Cspan class=\"nx\">z\u003C/span>\u003Cspan class=\"p\">));\u003C/span>\n\u003Cspan class=\"p\">}\u003C/span>\n\u003C/code>\u003C/pre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C/title>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C/path>\n\u003C/svg>\n\n    \u003Csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C/title>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C/path>\n\u003C/svg>\n\n\u003C/div>\n\u003C/div>\n\u003C/div>\n\n\n\n\u003Cp>The tiny \u003Ccode>u1\u003C/code> floor prevents \u003Ccode>Math.log(0)\u003C/code>. With volatility set to zero, the function returns the average instead of needlessly consuming random samples. With volatility enabled, spending is non-negative and usually clustered around ordinary values with a longer expensive tail. “Log-normal-style” is deliberate wording: it is a convenient shape for a toy model, not a claim that health expenses follow this exact distribution.\u003C/p>\n\n\u003Cp>The Monte Carlo loop generates one spend per plan-year and sends that same number to both plans:\u003Cbr>\n\u003C/p>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight javascript\">\u003Ccode>\u003Cspan class=\"k\">for \u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"kd\">let\u003C/span> \u003Cspan class=\"nx\">r\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">;\u003C/span> \u003Cspan class=\"nx\">r\u003C/span> \u003Cspan class=\"o\">&lt;\u003C/span> \u003Cspan class=\"nx\">runs\u003C/span>\u003Cspan class=\"p\">;\u003C/span> \u003Cspan class=\"nx\">r\u003C/span>\u003Cspan class=\"o\">++\u003C/span>\u003Cspan class=\"p\">)\u003C/span> \u003Cspan class=\"p\">{\u003C/span>\n  \u003Cspan class=\"kd\">let\u003C/span> \u003Cspan class=\"nx\">totalA\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">;\u003C/span>\n  \u003Cspan class=\"kd\">let\u003C/span> \u003Cspan class=\"nx\">totalB\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">;\u003C/span>\n  \u003Cspan class=\"k\">for \u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"kd\">let\u003C/span> \u003Cspan class=\"nx\">y\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">;\u003C/span> \u003Cspan class=\"nx\">y\u003C/span> \u003Cspan class=\"o\">&lt;\u003C/span> \u003Cspan class=\"nx\">years\u003C/span>\u003Cspan class=\"p\">;\u003C/span> \u003Cspan class=\"nx\">y\u003C/span>\u003Cspan class=\"o\">++\u003C/span>\u003Cspan class=\"p\">)\u003C/span> \u003Cspan class=\"p\">{\u003C/span>\n    \u003Cspan class=\"kd\">const\u003C/span> \u003Cspan class=\"nx\">spend\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nf\">annualMedicalSpend\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">state\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nx\">avgSpend\u003C/span>\u003Cspan class=\"p\">,\u003C/span>\n      \u003Cspan class=\"nx\">state\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nx\">spendVolatility\u003C/span>\u003Cspan class=\"p\">);\u003C/span>\n    \u003Cspan class=\"nx\">totalA\u003C/span> \u003Cspan class=\"o\">+=\u003C/span> \u003Cspan class=\"nf\">planOutOfPocket\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">state\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nx\">planA\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">spend\u003C/span>\u003Cspan class=\"p\">);\u003C/span>\n    \u003Cspan class=\"nx\">totalB\u003C/span> \u003Cspan class=\"o\">+=\u003C/span> \u003Cspan class=\"nf\">planOutOfPocket\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">state\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nx\">planB\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">spend\u003C/span>\u003Cspan class=\"p\">);\u003C/span>\n  \u003Cspan class=\"p\">}\u003C/span>\n  \u003Cspan class=\"nx\">planA\u003C/span>\u003Cspan class=\"p\">[\u003C/span>\u003Cspan class=\"nx\">r\u003C/span>\u003Cspan class=\"p\">]\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nx\">totalA\u003C/span>\u003Cspan class=\"p\">;\u003C/span>\n  \u003Cspan class=\"nx\">planB\u003C/span>\u003Cspan class=\"p\">[\u003C/span>\u003Cspan class=\"nx\">r\u003C/span>\u003Cspan class=\"p\">]\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nx\">totalB\u003C/span>\u003Cspan class=\"p\">;\u003C/span>\n\u003Cspan class=\"p\">}\u003C/span>\n\u003C/code>\u003C/pre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C/title>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C/path>\n\u003C/svg>\n\n    \u003Csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C/title>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C/path>\n\u003C/svg>\n\n\u003C/div>\n\u003C/div>\n\u003C/div>\n\n\n\n\u003Cp>That shared path is the key comparison control. If Plan A and Plan B each generated their own random spending, the difference would mix policy design with unrelated luck. In one run, both see the same ordinary year, bad year, and expensive year; only premium, deductible, coinsurance, and cap rules differ.\u003C/p>\n\n\u003Ch2>\n  \u003Ca name=\"deductible-coinsurance-and-cap-have-an-order\" href=\"#deductible-coinsurance-and-cap-have-an-order\">\n  \u003C/a>\n  Deductible, coinsurance, and cap have an order\n\u003C/h2>\n\n\u003Cp>\u003Ccode>planOutOfPocket\u003C/code> starts with annual premium. Medical spending up to the deductible is paid fully by the member. Above it, the deductible is combined with the configured coinsurance share of the remainder. Finally, a positive out-of-pocket maximum caps that member portion:\u003Cbr>\n\u003C/p>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight javascript\">\u003Ccode>\u003Cspan class=\"kd\">function\u003C/span> \u003Cspan class=\"nf\">planOutOfPocket\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">plan\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">medicalSpend\u003C/span>\u003Cspan class=\"p\">)\u003C/span> \u003Cspan class=\"p\">{\u003C/span>\n  \u003Cspan class=\"kd\">const\u003C/span> \u003Cspan class=\"nx\">premium\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">max\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">plan\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nx\">annualPremium\u003C/span> \u003Cspan class=\"o\">||\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">);\u003C/span>\n  \u003Cspan class=\"kd\">const\u003C/span> \u003Cspan class=\"nx\">deductible\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">max\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">plan\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nx\">deductible\u003C/span> \u003Cspan class=\"o\">||\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">);\u003C/span>\n  \u003Cspan class=\"kd\">const\u003C/span> \u003Cspan class=\"nx\">oopMax\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">max\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">plan\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nx\">oopMax\u003C/span> \u003Cspan class=\"o\">||\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">);\u003C/span>\n  \u003Cspan class=\"kd\">const\u003C/span> \u003Cspan class=\"nx\">coinsurance\u003C/span> \u003Cspan class=\"o\">=\u003C/span>\n    \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">min\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"mi\">100\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">max\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">plan\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nx\">coinsurance\u003C/span> \u003Cspan class=\"o\">||\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">))\u003C/span> \u003Cspan class=\"o\">/\u003C/span> \u003Cspan class=\"mi\">100\u003C/span>\u003Cspan class=\"p\">;\u003C/span>\n  \u003Cspan class=\"kd\">let\u003C/span> \u003Cspan class=\"nx\">oop\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nx\">medicalSpend\u003C/span> \u003Cspan class=\"o\">&lt;=\u003C/span> \u003Cspan class=\"nx\">deductible\u003C/span>\n    \u003Cspan class=\"p\">?\u003C/span> \u003Cspan class=\"nx\">medicalSpend\u003C/span>\n    \u003Cspan class=\"p\">:\u003C/span> \u003Cspan class=\"nx\">deductible\u003C/span> \u003Cspan class=\"o\">+\u003C/span> \u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">medicalSpend\u003C/span> \u003Cspan class=\"o\">-\u003C/span> \u003Cspan class=\"nx\">deductible\u003C/span>\u003Cspan class=\"p\">)\u003C/span> \u003Cspan class=\"o\">*\u003C/span> \u003Cspan class=\"nx\">coinsurance\u003C/span>\u003Cspan class=\"p\">;\u003C/span>\n  \u003Cspan class=\"k\">if \u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">oopMax\u003C/span> \u003Cspan class=\"o\">&gt;\u003C/span> \u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">)\u003C/span> \u003Cspan class=\"nx\">oop\u003C/span> \u003Cspan class=\"o\">=\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">min\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"nx\">oop\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">oopMax\u003C/span>\u003Cspan class=\"p\">);\u003C/span>\n  \u003Cspan class=\"k\">return\u003C/span> \u003Cspan class=\"nx\">premium\u003C/span> \u003Cspan class=\"o\">+\u003C/span> \u003Cspan class=\"nb\">Math\u003C/span>\u003Cspan class=\"p\">.\u003C/span>\u003Cspan class=\"nf\">max\u003C/span>\u003Cspan class=\"p\">(\u003C/span>\u003Cspan class=\"mi\">0\u003C/span>\u003Cspan class=\"p\">,\u003C/span> \u003Cspan class=\"nx\">oop\u003C/span>\u003Cspan class=\"p\">);\u003C/span>\n\u003Cspan class=\"p\">}\u003C/span>\n\u003C/code>\u003C/pre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C/title>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C/path>\n\u003C/svg>\n\n    \u003Csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C/title>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C/path>\n\u003C/svg>\n\n\u003C/div>\n\u003C/div>\n\u003C/div>\n\n\n\n\u003Cp>For example, with a 3,000 deductible, 20% coinsurance, and 7,000 cap, a 1,500 spend produces 1,500 member cost before premium. A 13,000 spend produces 3,000 plus 20% of 10,000, or 5,000, still below the cap. The annual premium is added regardless of whether a claim happens. This is a simplified annual rule: it does not model service categories, network pricing, copays, or a deductible that resets on a different schedule.\u003C/p>\n\n\u003Ch2>\n  \u003Ca name=\"read-distributions-instead-of-chasing-one-winner\" href=\"#read-distributions-instead-of-chasing-one-winner\">\n  \u003C/a>\n  Read distributions instead of chasing one winner\n\u003C/h2>\n\n\u003Cp>For each run, the component totals every simulated year's cost. The results are sorted to report mean, median, 10th percentile, 90th percentile, and the share of runs where Plan A is cheaper. The chart reuses those arrays, so it shows a distribution rather than a single break-even claim. A high-deductible plan may have the lower mean but a much wider high-cost tail; a richer plan may cost more in most routine paths while limiting unpleasant surprises.\u003C/p>\n\n\u003Cp>Try 10 years and 5,000 runs, then rerun with volatility at zero. The zero-volatility version isolates policy math; the volatile version shows how premiums trade against exposure. Repeated clicks will not reproduce identical values because the source uses \u003Ccode>Math.random()\u003C/code> and does not seed it. That is useful for seeing variability, but inconvenient for a reproducible audit.\u003C/p>\n\n\u003Cp>There are also practical bounds behind the controls. The simulation enforces at least one year and at least 100 runs even if a malformed value reaches the calculation, while the normal selector offers 500 through 10,000 runs. More runs generally make the displayed distribution less noisy, but they do not repair a bad average-spend assumption. In other words, increasing computational effort cannot turn an invented input into reliable insurance underwriting data.\u003C/p>\n\n\u003Ch2>\n  \u003Ca name=\"honest-inputs-are-part-of-the-algorithm\" href=\"#honest-inputs-are-part-of-the-algorithm\">\n  \u003C/a>\n  Honest inputs are part of the algorithm\n\u003C/h2>\n\n\u003Cp>The form asks for years, runs, average annual spending, volatility, and each plan's four parameters. It does not contain a disease-rate or insurer database. Outputs are conditional on those assumptions, and currency is not inherently tied to one country's policy vocabulary. Real policies can have exclusions, eligible-service rules, family deductibles, and claim limits this model cannot represent. It should support questions for an insurer, not replace policy wording or professional advice. I turned this experiment into a small free tool: \u003Ca href=\"https://begoodtool.com/insurance-deductible-simulator/en\" target=\"_blank\" rel=\"noopener noreferrer\">Insurance Deductible Scenario Simulator\u003C/a>.\u003C/p>\n\n","The hard part of comparing a high-deductible, low-premium plan with a low-deductible plan is not adding two premiums. Medical spending varies, and a fair comparison should expose both ordinary and expensive years. I built this simulator so both plans see the same generated spending path; otherwise random noise can make one plan look better simply because it received easier years. The useful audience is someone who can read a spreadsheet or a little JavaScript and wants to reason about uncertainty without mistaking a simulation for an insurer's forecast.\r\n\r\n## Generate one annual spend, then apply both plan rules\r\n\r\nAnnual spending uses a log-normal-style transformation. First, `randomStandardNormal()` makes a normal deviate with the Box-Muller transform. Then volatility becomes `sigma`, and the result is exponentiated and clamped:\r\n\r\n```js\r\nfunction randomStandardNormal() {\r\n  let u1 = Math.random();\r\n  const u2 = Math.random();\r\n  if (u1 \u003C= 1e-12) u1 = 1e-12;\r\n  return Math.sqrt(-2 * Math.log(u1)) *\r\n    Math.cos(2 * Math.PI * u2);\r\n}\r\n\r\nfunction annualMedicalSpend(avg, volatilityPct) {\r\n  const sigma = Math.max(0, volatilityPct || 0) / 100;\r\n  if (sigma === 0) return Math.max(0, avg || 0);\r\n  const z = randomStandardNormal();\r\n  return Math.max(0, (avg || 0) *\r\n    Math.exp(-0.5 * sigma * sigma + sigma * z));\r\n}\r\n```\r\n\r\nThe tiny `u1` floor prevents `Math.log(0)`. With volatility set to zero, the function returns the average instead of needlessly consuming random samples. With volatility enabled, spending is non-negative and usually clustered around ordinary values with a longer expensive tail. “Log-normal-style” is deliberate wording: it is a convenient shape for a toy model, not a claim that health expenses follow this exact distribution.\r\n\r\nThe Monte Carlo loop generates one spend per plan-year and sends that same number to both plans:\r\n\r\n```js\r\nfor (let r = 0; r \u003C runs; r++) {\r\n  let totalA = 0;\r\n  let totalB = 0;\r\n  for (let y = 0; y \u003C years; y++) {\r\n    const spend = annualMedicalSpend(state.avgSpend,\r\n      state.spendVolatility);\r\n    totalA += planOutOfPocket(state.planA, spend);\r\n    totalB += planOutOfPocket(state.planB, spend);\r\n  }\r\n  planA[r] = totalA;\r\n  planB[r] = totalB;\r\n}\r\n```\r\n\r\nThat shared path is the key comparison control. If Plan A and Plan B each generated their own random spending, the difference would mix policy design with unrelated luck. In one run, both see the same ordinary year, bad year, and expensive year; only premium, deductible, coinsurance, and cap rules differ.\r\n\r\n## Deductible, coinsurance, and cap have an order\r\n\r\n`planOutOfPocket` starts with annual premium. Medical spending up to the deductible is paid fully by the member. Above it, the deductible is combined with the configured coinsurance share of the remainder. Finally, a positive out-of-pocket maximum caps that member portion:\r\n\r\n```js\r\nfunction planOutOfPocket(plan, medicalSpend) {\r\n  const premium = Math.max(0, plan.annualPremium || 0);\r\n  const deductible = Math.max(0, plan.deductible || 0);\r\n  const oopMax = Math.max(0, plan.oopMax || 0);\r\n  const coinsurance =\r\n    Math.min(100, Math.max(0, plan.coinsurance || 0)) / 100;\r\n  let oop = medicalSpend \u003C= deductible\r\n    ? medicalSpend\r\n    : deductible + (medicalSpend - deductible) * coinsurance;\r\n  if (oopMax > 0) oop = Math.min(oop, oopMax);\r\n  return premium + Math.max(0, oop);\r\n}\r\n```\r\n\r\nFor example, with a 3,000 deductible, 20% coinsurance, and 7,000 cap, a 1,500 spend produces 1,500 member cost before premium. A 13,000 spend produces 3,000 plus 20% of 10,000, or 5,000, still below the cap. The annual premium is added regardless of whether a claim happens. This is a simplified annual rule: it does not model service categories, network pricing, copays, or a deductible that resets on a different schedule.\r\n\r\n## Read distributions instead of chasing one winner\r\n\r\nFor each run, the component totals every simulated year's cost. The results are sorted to report mean, median, 10th percentile, 90th percentile, and the share of runs where Plan A is cheaper. The chart reuses those arrays, so it shows a distribution rather than a single break-even claim. A high-deductible plan may have the lower mean but a much wider high-cost tail; a richer plan may cost more in most routine paths while limiting unpleasant surprises.\r\n\r\nTry 10 years and 5,000 runs, then rerun with volatility at zero. The zero-volatility version isolates policy math; the volatile version shows how premiums trade against exposure. Repeated clicks will not reproduce identical values because the source uses `Math.random()` and does not seed it. That is useful for seeing variability, but inconvenient for a reproducible audit.\r\n\r\nThere are also practical bounds behind the controls. The simulation enforces at least one year and at least 100 runs even if a malformed value reaches the calculation, while the normal selector offers 500 through 10,000 runs. More runs generally make the displayed distribution less noisy, but they do not repair a bad average-spend assumption. In other words, increasing computational effort cannot turn an invented input into reliable insurance underwriting data.\r\n\r\n## Honest inputs are part of the algorithm\r\n\r\nThe form asks for years, runs, average annual spending, volatility, and each plan's four parameters. It does not contain a disease-rate or insurer database. Outputs are conditional on those assumptions, and currency is not inherently tied to one country's policy vocabulary. Real policies can have exclusions, eligible-service rules, family deductibles, and claim limits this model cannot represent. It should support questions for an insurer, not replace policy wording or professional advice. I turned this experiment into a small free tool: [Insurance Deductible Scenario Simulator](https://begoodtool.com/insurance-deductible-simulator/en).",{"name":30,"username":31,"twitter_username":14,"github_username":14,"user_id":32,"website_url":33,"profile_image":34,"profile_image_90":35},"Joe Lin","yuntao_lin",4066889,"https://begoodtool.com/home/en","https://media2.dev.to/dynamic/image/width=640,height=640,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4066889%2Fcbfd5bde-d893-4635-97d5-aea05722cb26.jpeg","https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4066889%2Fcbfd5bde-d893-4635-97d5-aea05722cb26.jpeg",{"name":37,"username":38,"slug":38,"profile_image":39,"profile_image_90":40},"BeGoodTool.com","begoodtool","https://media2.dev.to/dynamic/image/width=640,height=640,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F14295%2Fd519278f-433a-4dab-9489-447ef51fc6d4.jpg","https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F14295%2Fd519278f-433a-4dab-9489-447ef51fc6d4.jpg",1788921586529]