Law of Total Probability Calculator
The law of total probability is the route to take when the probability of an event cannot be found directly: the sample space is split into mutually exclusive, exhaustive branches A₁, A₂, …, Aₙ, and the probability is computed as the sum P(B) = ΣP(B|Aᵢ)·P(Aᵢ). The overall defect rate of a factory is the sum of the defect rates of its lines weighted by their share of production; the average resolution rate of a call center is the sum of the shift resolution rates weighted by the share of each shift.
This calculator works from one branch per line: the prior probability of the branch P(Aᵢ) and the conditional probability inside that branch P(B|Aᵢ). The output gives not only P(B) but also how much each branch adds to the total, the share each one carries, and the posterior probabilities P(Aᵢ|B) obtained from Bayes' theorem. That way the question "given that B happened, which branch did it most likely come from" is answered on the same screen.
The Law of Total Probability
Total probability: P(B) = Σᵢ P(B|Aᵢ) · P(Aᵢ) Partition: Aᵢ ∩ Aⱼ = ∅ (i ≠ j) and Σᵢ P(Aᵢ) = 1 Two-branch case: P(B) = P(B|A)·P(A) + P(B|Aʹ)·P(Aʹ) Branch contribution: P(Aᵢ ∩ B) = P(Aᵢ) · P(B|Aᵢ) Posterior (Bayes): P(Aᵢ|B) = P(B|Aᵢ)·P(Aᵢ) / P(B) Check: Σᵢ P(Aᵢ|B) = 1 Bounds: min P(B|Aᵢ) ≤ P(B) ≤ max P(B|Aᵢ)
The rule amounts to adding up the products along the branches of a probability tree. Once P(B) has been computed as the denominator, Bayes' theorem can be applied directly with the same numbers, which is why this calculator reports the posterior probabilities alongside it.
How to Calculate
- Split the sample space into mutually exclusive branches: production lines, shifts, customer segments, weather scenarios, and so on.
- Write one branch per line: first the probability of the branch P(Aᵢ), then a semicolon and the conditional probability inside that branch P(B|Aᵢ).
- If you like, add a label such as 'Factory A:' at the start of a line; that name is used in the table and the charts.
- Choose whether you entered the probabilities as decimals or percentages, and make sure the branch probabilities add up to 1 (or 100).
- Compare the P(B) result with the range of the conditional probabilities; the result must always fall between the smallest and the largest conditional.
- Read the posterior P(Aᵢ|B) column in the table: it shows which branch becomes more likely to be responsible once the event has occurred.
Worked Examples
Defective items from three factories
Half of the output comes from factory A, 30% from factory B, and 20% from factory C, with defect rates of 2%, 3%, and 5% respectively. The total probability of a defect is P(B) = 0.50×0.02 + 0.30×0.03 + 0.20×0.05 = 0.010 + 0.009 + 0.010 = 0.029, that is 2.90%. A randomly picked defective item comes from A with probability 34.48%, from B with 31.03%, and from C with 34.48%: factory C, which has the smallest share, carries the same responsibility as A thanks to its high defect rate.
P(Kusurlu) — total probability: 2.90% · P(not Kusurlu): 97.10% · Number of branches: 3
Error rate by shift (percentage input)
45% of the transactions are handled on the morning shift, 35% at midday, and 20% at night, with error rates of 1.5%, 2.5%, and 4% respectively. The total probability of an error is 2.35%. The probability that a faulty transaction came from the night shift rises to 34.04%, even though the night shift handles only 20% of the transactions.
P(Hatalı işlem) — total probability: 2.35% · P(not Hatalı işlem): 97.65% · Number of branches: 3
A two-branch weather scenario
30% of the days are rainy; the probability of a delay is 60% on rainy days and 10% on dry ones. The total probability of a delay is 0.30×0.60 + 0.70×0.10 = 0.18 + 0.07 = 0.25, that is 25%. When a delay does occur, the probability that the day was rainy rises to 72%; the prior probability of 30% has more than doubled.
P(Gecikme) — total probability: 25.00% · P(not Gecikme): 75.00% · Number of branches: 2