{
  "schemaVersion": 1,
  "slug": "probability-calculator",
  "category": "math",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "be249f69ad310394f37b2ea96832505b8ab9c0474a011dca8161fe602e418d77",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/probability-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "P(A∩B) = P(A)P(B); P(A∪B) = P(A) + P(B) − P(A∩B); O = P(A∩B) ÷ (1 − P(A∩B))",
    "vars": [
      [
        "P(A)",
        "Probability of A"
      ],
      [
        "P(B)",
        "Probability of B"
      ],
      [
        "P(A∩B)",
        "Both occur"
      ],
      [
        "P(A∪B)",
        "Either occurs"
      ],
      [
        "O",
        "Odds for both"
      ]
    ],
    "note": "Assumes independent events and probabilities from 0 to 1. Odds are p ÷ (1 − p); when p = 1, odds are infinite and shown as an em dash."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-12",
    "sources": [
      {
        "name": "OpenStax — Probability and combinations",
        "url": "https://openstax.org/books/introductory-statistics-2e/pages/3-introduction"
      }
    ],
    "referenceRole": "definition",
    "implementationHash": "be249f69ad310394f37b2ea96832505b8ab9c0474a011dca8161fe602e418d77",
    "basis": "P(A∩B) = P(A)P(B); P(A∪B) = P(A) + P(B) − P(A∩B); O = P(A∩B) ÷ (1 − P(A∩B))",
    "limitations": "The references explain definitions and methods; any extra preset must be checked against the assumptions on this page."
  },
  "contract": {
    "compute": "const both=pa*pb,either=pa+pb-both;return {both,either,neither:1-either,onlyA:pa-both,oddsBoth:both>=1?null:both>0?both/(1-both):0};",
    "inputs": [
      {
        "name": "pa",
        "type": "number",
        "default": 0.5,
        "min": 0,
        "max": 1,
        "step": 0.001,
        "slider": true
      },
      {
        "name": "pb",
        "type": "number",
        "default": 0.3,
        "min": 0,
        "max": 1,
        "step": 0.001,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "both",
        "precision": 6,
        "unit": ""
      },
      {
        "name": "either",
        "precision": 6,
        "unit": ""
      },
      {
        "name": "neither",
        "precision": 6,
        "unit": ""
      },
      {
        "name": "onlyA",
        "precision": 6,
        "unit": ""
      },
      {
        "name": "oddsBoth",
        "precision": 4,
        "unit": "",
        "optional": true
      }
    ],
    "interpret": null
  }
}
