Bayes’ Theorem Calculator & Evidence Tree

Use Bayes’ theorem to update the probability of an event after a check. Enter the positive rates within the event and other groups, then choose which result you observed. Add a follow-up with rates measured among cases that reached it. Compare expected counts and posterior probabilities, and see which starting event share reaches a threshold you choose.

Conditional probability

Update a probability as evidence arrives

See how a first check and a follow-up change a starting probability. Find the starting share you need to reach your decision threshold.

Cohort and decision target

Cohort and decision target

The event is the outcome you want to identify. In the example, it means a part is actually defective.

First check

First check

Follow-up check

Follow-up check

Enter likelihoods only among cases with a positive first result.

First positive → positive gives a 46.3415% probability of the event.

Event after selected path
46.3415%
After the first check · 15.3846%
Share reaching this path
1.845%
369 of 20,000 expected
Minimum starting share
1.1561%
Needed for a 50% posterior.
How starting share changes the answer
  • First check
  • With follow-up
  • Target posterior
Starting probability versus posterior probabilityProbability after each selected check as the starting event share varies from 0 to 5%. At the current starting share of 1%, the last posterior is 46.3415%. The required posterior is 50%.0%50%100%0%2.5%5%

The ring marks the current input. The horizontal axis shows starting event share. The vertical axis shows posterior event probability.

Evidence tree

Each bar shows the mix of event and other cases among those who reach that path.

First check

  • First positive

    5.85% of the cohort reaches this path

    Event 15.3846%Other 84.6154%

  • First negative

    94.15% of the cohort reaches this path

    Event 0.1062%Other 99.8938%

Follow-up after a positive first result

  • First positive → positive (selected path)

    1.845% of the cohort reaches this path

    Event 46.3415%Other 53.6585%

  • First positive → negative

    4.005% of the cohort reaches this path

    Event 1.1236%Other 98.8764%

Expected counts by evidence path

Counts are averages for the entered cohort and can be fractional. The last two rows split the selected first result.

PathEventOtherPath sharePosterior
First positive1809905.85%15.3846%
First negative2018,81094.15%0.1062%
First positive → positive (selected path)1711981.845%46.3415%
First positive → negative97924.005%1.1236%
Download evidence CSV
Show selectable CSV

How to use this calculator

  1. Enter the starting share of cases where the event is present, such as the share of genuinely defective items, and a cohort size for expected counts.
  2. Enter how often the first check would be positive within each of the two groups. Choose the first outcome you observed.
  3. For a follow-up, enter positive rates measured only among cases with the selected first result. Each first result keeps its own draft rates. Select the follow-up outcome you observed.
  4. Compare the selected posterior with the starting share. Enter a target posterior and use the chart and minimum starting share to see when the selected evidence would reach it.
  5. Read both groups’ expected counts for each path in the table. Download or copy the CSV to retain the underlying values.

The Formula

The mathematical logic powering this calculation is:

Let H be the event and p = P(H) its starting probability. For any selected observation path R, enter or derive a = P(R | H) and b = P(R | not H). Each path share is p × a + (1 − p) × b. Bayes’ theorem gives P(H | R) = p × a / [p × a + (1 − p) × b] when the denominator is positive. The probability of a negative check is the complement of the positive rate within the same group.

For a second check, multiply P(first result | H) by P(second result | H and first result). Apply the same chain to the other group. This uses the two separate conditional rates you enter for the observed first result. Expected counts multiply the resulting joint probabilities by the cohort size. They can be fractional.

For target posterior t between 0 and 1 and both likelihoods positive, the minimum prior is t × b / [(1 − t) × a + t × b]. A path produced only by the event reaches any such target for all positive priors. A path produced only by the other group cannot reach it. A path with no likelihood in either group has undefined posterior for every prior.

Cohort size is a whole number from 1 to 1,000,000,000. Enter rates from 0 to 100% with up to six decimal places. The target excludes both endpoints. The model treats the entered rates as fixed inputs and reports fractional expected counts. Rounded chart and table labels are for reading. The CSV stores the same underlying probabilities as fractions from 0 to 1 and leaves undefined posteriors empty.

Worked Example

If you input:

  • Cohort size: 20,000 items
  • Starting defective share: 1%
  • First check positive rates: 90% of defective items, 5% of other items
  • Follow-up positive rates among flagged items: 95% of defective items, 20% of other items
  • Observed results: Positive, then positive
  • Required posterior: 50%

Result:

The first positive results include 180 defective and 990 other items in expectation. The probability of a defect given that result is 15.3846%. The positive follow-up retains 171 defective and 198 other items, raising the posterior to 46.3415%. This path reaches a 50% posterior at a starting share of about 1.1561%.

Frequently Asked Questions

Is a 90% positive rate among event cases the same as a 90% posterior?

These are different conditional probabilities. The posterior divides the event cases on the selected path by all cases on that path. It therefore depends on the starting share and how frequently other cases produce the same result.

Why does the same check give a lower posterior at lower base rates?

When the event is rarer, a fixed false-positive likelihood can send more other cases than event cases to the positive result. The sensitivity curve shows the effect while holding the entered check likelihoods fixed.

Which rates belong in the follow-up?

Use rates for the follow-up among cases with the selected first outcome, separately within the event group and the other group. An overall follow-up rate from every case may not describe the group that actually reached the follow-up.

Why does the table show fractional counts?

The table shows expected counts calculated by multiplying joint probabilities by the cohort size. Actual observed counts are whole numbers and can vary around those expectations.

What does an undefined posterior mean?

The selected path has zero probability under the entered starting share and rates. The formula has no valid denominator. A possible path with no event cases has a defined posterior of 0%.

What does any positive prior mean for the minimum?

The selected path is possible only in the event group. Any prior above 0% yields a 100% posterior along that path. At exactly 0%, the path never occurs and the posterior is undefined.

Similar Calculators