{
  "id": "law-of-total-probability",
  "title": "Law of Total Probability",
  "lang": "en",
  "source_lang": "en",
  "summary": "The law of total probability computes an event’s probability by averaging its conditional probabilities over an exhaustive collection of mutually exclusive cases.",
  "category": "mathematics",
  "subcategory": "probability-statistics",
  "type": "concept",
  "aliases": [
    "Total probability theorem",
    "Total probability formula"
  ],
  "generated_at": "2026-11-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/law-of-total-probability/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/law-of-total-probability/",
      "json": "https://aiwiki.page/zh/law-of-total-probability.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The law of total probability is a theorem in probability theory that expresses the probability of an event as a weighted sum of its probabilities under different conditions. When those conditions form mutually exclusive and exhaustive cases, each conditional probability is weighted by the probability of its case. The law provides a basic method for calculating probabilities indirectly, underlies the denominator in Bayes’ theorem, and extends to integration over continuously varying conditions."
    },
    {
      "heading": "Statement",
      "text": "Let \\((\\Omega,\\mathcal F,P)\\) be a probability space, and let \\(A\\) be an event. Suppose that \\(B_1,\\ldots,B_n\\) are measurable events forming a partition of the sample space:\n\n\\[B_i\\cap B_j=\\varnothing \\quad\\text{for }i\\ne j, \\qquad \\bigcup_{i=1}^{n}B_i=\\Omega.\\]\n\nIf \\(P(B_i)>0\\) for every \\(i\\), then\n\n\\[\\boxed{ P(A)=\\sum_{i=1}^{n}P(A\\mid B_i)P(B_i) }\\]\n\nHere \\(P(A\\mid B_i)\\) denotes the conditional probability of \\(A\\) given \\(B_i\\).\n\nThe same formula holds for a countably infinite partition:\n\n\\[P(A)=\\sum_{i=1}^{\\infty}P(A\\mid B_i)P(B_i).\\]\n\nThe terms are nonnegative, and the series converges to a value in \\([0,1]\\). The cases may also cover the sample space only up to an event of probability zero; the result is unchanged.\n\nAn equivalent statement, which does not require positive probabilities for the partition events, is\n\n\\[P(A)=\\sum_i P(A\\cap B_i).\\]\n\nIf some \\(B_i\\) has probability zero, its intersection with \\(A\\) also has probability zero. Such terms can be omitted from the conditional-probability formula, rather than attempting to define the ratio \\(P(A\\cap B_i)/P(B_i)\\).\n\nTwo-case form\n\nA common special case uses an event \\(B\\) and its complement \\(B^c\\). When \\(0<P(B)<1\\),\n\n\\[P(A) = P(A\\mid B)P(B) + P(A\\mid B^c)P(B^c).\\]\n\nThis separates the calculation into two possibilities: \\(B\\) occurs, or it does not."
    },
    {
      "heading": "Proof and interpretation",
      "text": "Because the partition events are mutually exclusive and exhaustive,\n\n\\[A=\\bigcup_i(A\\cap B_i),\\]\n\nand the events \\(A\\cap B_i\\) are mutually exclusive. Countable additivity therefore gives\n\n\\[P(A)=\\sum_i P(A\\cap B_i).\\]\n\nBy the definition of conditional probability,\n\n\\[P(A\\cap B_i)=P(A\\mid B_i)P(B_i)\\]\n\nwhenever \\(P(B_i)>0\\). Substitution proves the formula.\n\nThe law is thus a consequence of the probability axioms and the definition of conditioning, rather than an additional assumption about a model.\n\nFor a finite partition, the formula expresses \\(P(A)\\) as a convex combination of the conditional probabilities: the weights \\(P(B_i)\\) are nonnegative and sum to one. Consequently,\n\n\\[\\min_i P(A\\mid B_i) \\le P(A)\\le \\max_i P(A\\mid B_i).\\]\n\nThe weights matter. An ordinary arithmetic average of the conditional probabilities is generally incorrect unless the cases are equally likely.\n\nNo assumption of statistical independence is required. If \\(A\\) is independent of every partition event, then \\(P(A\\mid B_i)=P(A)\\) for each positive-probability case, and the formula reduces to\n\n\\[P(A)=P(A)\\sum_i P(B_i).\\]"
    },
    {
      "heading": "Example: production from several factories",
      "text": "Suppose a distributor receives products from three factories:\n\nFactory | Share of products | Probability of a defect\n1 | \\(0.50\\) | \\(0.01\\)\n2 | \\(0.30\\) | \\(0.02\\)\n3 | \\(0.20\\) | \\(0.04\\)\n\nLet \\(D\\) be the event that a randomly selected product is defective, and let \\(B_i\\) identify its factory. Then\n\n\\[\\begin{aligned} P(D) &=P(D\\mid B_1)P(B_1) +P(D\\mid B_2)P(B_2) +P(D\\mid B_3)P(B_3)\\\\ &=(0.01)(0.50)+(0.02)(0.30)+(0.04)(0.20)\\\\ &=0.019. \\end{aligned}\\]\n\nThe overall defect probability is therefore \\(1.9\\%\\). The unweighted average of the three factory defect rates is approximately \\(2.33\\%\\), but that calculation ignores their different contributions to the distributor’s supply.\n\nThe relevant weights depend on the sampling procedure. Choosing a factory uniformly and then choosing one of its products would describe a different experiment from choosing a product uniformly from the distributor’s inventory."
    },
    {
      "heading": "Conditional form",
      "text": "The law can itself be applied within a conditioning event. If \\(P(C)>0\\), then\n\n\\[P(A\\mid C) = \\sum_i P(A\\mid B_i\\cap C)P(B_i\\mid C),\\]\n\nwhere terms with \\(P(B_i\\cap C)=0\\) are omitted.\n\nThis is the ordinary law applied to the probability measure \\(P(\\,\\cdot\\mid C)\\). Both the case probabilities and the within-case probabilities must be evaluated under the additional information \\(C\\). In general, the unconditional weights \\(P(B_i)\\) cannot be substituted for \\(P(B_i\\mid C)\\)."
    },
    {
      "heading": "Random-variable and continuous forms",
      "text": "Conditioning on a discrete random variable\n\nIf a random variable \\(X\\) takes finitely or countably many values, the events \\(\\{X=x\\}\\) form a partition. Hence\n\n\\[P(A)=\\sum_{x:P(X=x)>0}P(A\\mid X=x)P(X=x).\\]\n\nThis formulation is useful when the cases are values of a count, category, state, or unobserved variable.\n\nConditioning on a continuous random variable\n\nIf \\(X\\) has a probability density function \\(f_X\\), the corresponding expression is\n\n\\[P(A)=\\int_{\\mathbb R}P(A\\mid X=x)f_X(x)\\,dx,\\]\n\nwith \\(P(A\\mid X=x)\\) interpreted through an appropriate version of conditional probability.\n\nFor a continuously distributed \\(X\\), each individual event \\(\\{X=x\\}\\) has probability zero. The conditional probability in this integral therefore cannot generally be defined by the elementary ratio\n\n\\[\\frac{P(A\\cap\\{X=x\\})}{P(X=x)}.\\]\n\nInstead, it is defined using conditional distributions or conditional expectation. Under standard regularity conditions, including the usual real-valued settings, suitable conditional distributions exist. Their values need only be specified for \\(P_X\\)-almost every \\(x\\), where \\(P_X\\) is the distribution of \\(X\\).\n\nMore generally, the integral form is\n\n\\[P(A)=\\int P(A\\mid X=x)\\,P_X(dx).\\]\n\nThis formulation also covers discrete and mixed distributions.\n\nMarginal distributions\n\nApplied to events involving another random variable \\(Y\\), total probability yields marginalization formulas. If \\(X\\) and \\(Y\\) have a joint density and \\(f_{Y\\mid X}\\) is a compatible conditional density, then\n\n\\[f_Y(y)=\\int_{\\mathbb R}f_{Y\\mid X}(y\\mid x)f_X(x)\\,dx\\]\n\nfor almost every \\(y\\).\n\nThus, eliminating an auxiliary variable by summing or integrating over its possible values is a distributional form of the law."
    },
    {
      "heading": "Connection with conditional expectation",
      "text": "The most general formulation uses conditional expectation. For a sub-σ-algebra \\(\\mathcal G\\subseteq\\mathcal F\\), define\n\n\\[P(A\\mid\\mathcal G) = E[\\mathbf 1_A\\mid\\mathcal G],\\]\n\nwhere \\(\\mathbf 1_A\\) is the indicator of \\(A\\). Then\n\n\\[\\boxed{ P(A)=E\\!\\left[P(A\\mid\\mathcal G)\\right]. }\\]\n\nThis is the law of iterated expectations applied to an indicator. More generally, for any integrable random variable \\(Y\\),\n\n\\[E[Y]=E\\!\\left[E[Y\\mid\\mathcal G]\\right].\\]\n\nWhen \\(\\mathcal G\\) is generated by a finite or countable partition, conditional probability is constant on each positive-probability partition event, and the expectation becomes the familiar weighted sum. This connects total probability with the broader theory of expectation without requiring conditioning events to have positive probability."
    },
    {
      "heading": "Applications",
      "text": "Bayesian inference\n\nFor hypotheses \\(B_i\\) forming a partition, Bayes’ theorem becomes\n\n\\[P(B_k\\mid A) = \\frac{P(A\\mid B_k)P(B_k)} {\\sum_i P(A\\mid B_i)P(B_i)}, \\qquad P(A)>0.\\]\n\nTotal probability supplies the denominator, which normalizes the updated probabilities.\n\nIn Bayesian inference, the corresponding continuous operation integrates a likelihood against a prior distribution. The resulting marginal likelihood is\n\n\\[p(y)=\\int p(y\\mid\\theta)\\,\\pi(d\\theta),\\]\n\nwhere \\(\\pi\\) is the prior probability measure.\n\nMixture distributions\n\nIn a model with a latent category \\(Z\\), the distribution of an observation is obtained by averaging its category-specific distributions:\n\n\\[P(Y\\in A) = \\sum_k P(Y\\in A\\mid Z=k)P(Z=k).\\]\n\nFor a Gaussian mixture model, this produces a weighted sum of normal densities. The component label supplies the partition, and the mixture weights supply its probabilities.\n\nMarkov chains\n\nFor a discrete-state Markov chain, conditioning on the state at an intermediate time gives\n\n\\[P(X_{n+m}=j\\mid X_0=i) = \\sum_k P(X_{n+m}=j\\mid X_n=k) P(X_n=k\\mid X_0=i),\\]\n\nfor relevant positive-probability conditioning events. The simplification of the first conditional probability uses the Markov property; the sum over intermediate states uses total probability. For time-homogeneous chains, this leads to the Chapman–Kolmogorov equations."
    },
    {
      "heading": "Conditions and common errors",
      "text": "- Overlapping cases cause double counting. The simple sum requires mutually exclusive cases. Overlapping events must first be replaced by a suitable partition or handled with another identity.\n- Incomplete cases omit probability. If the selected cases do not cover the sample space up to probability zero, a residual case is needed.\n- Conditional probabilities require weights. Adding \\(P(A\\mid B_i)\\) alone does not generally produce \\(P(A)\\).\n- Zero-probability conditioning needs care. Elementary conditional probabilities are undefined when the conditioning event has probability zero; continuous conditioning requires a more general construction.\n- Uncountable partitions require integration. Countable additivity does not justify an uncountable sum over individual outcomes. In particular, summing zero-probability singleton events is not a valid way to calculate a continuous probability.\n- Conditioning is not intervention. The formula concerns observational conditional probabilities. Its terms do not, by themselves, describe the effects of changing or intervening on the conditioning variable; that distinction belongs to causal inference."
    }
  ],
  "links": [
    "probability",
    "bayes-theorem",
    "probability-space",
    "event-probability",
    "set-partition",
    "sample-space",
    "conditional-probability",
    "convex-combination",
    "statistical-independence",
    "random-variable",
    "probability-density-function",
    "probability-distribution",
    "joint-probability-distribution",
    "conditional-expectation",
    "sigma-algebra",
    "indicator-function",
    "expected-value",
    "bayesian-inference",
    "marginal-likelihood",
    "gaussian-mixture-model",
    "markov-chain",
    "chapman-kolmogorov-equations",
    "causal-inference"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}