Conditional Probability Calculator
A positive test, a turned card, a signed contract: once one event has happened, every other probability changes. This conditional probability calculator finds P(A|B), the chance of A given that B already happened, in nine modes covering whatever form your numbers arrive in: probabilities, percentages, raw counts, or the reverse conditional flipped with Bayes’ theorem.
Every mode shows the answer as a decimal and a percentage with the full working, and every input is validated, because conditional probability punishes inconsistent numbers quietly. If your question is about an average outcome instead of a single event, that is the conditional expected value tool linked further down; this page is about the probability itself.
First input. In probability modes this is P(A): in the worked example, having the condition, 1 percent. In single-event mode it becomes the favorable outcome count.
Second input. In probability modes this is P(B): in the worked example, testing positive, 8 percent. In single-event mode it becomes the total outcome count.
Probability of both together. It can never exceed P(A) or P(B), and the tool enforces that.
Every probability must lie between 0 and 1. The joint probability P(A and B) can never exceed either individual probability.
Quick Answer
Key takeaways
- Conditional probability shrinks the sample space: P(A|B) is the share of the B outcomes in which A also happens, P(A and B) / P(B).
- P(A|B) and P(B|A) are different numbers with different meanings. Swapping them is the base-rate error behind most misread medical tests and courtroom statistics.
- Counts are probabilities in disguise: 45 out of 93 is a conditional probability you can check by eye, which is why the counts mode exists.
- The joint probability can never exceed either single probability. Inputs that break that rule are inconsistent, and this tool says so instead of dividing anyway.
- Quick Answer
- How to use this calculator: pick the mode that matches your numbers
- The formula: the same fraction, inside a smaller world
- Worked example: a positive test that still means 11.25%
- Counts mode: the same math with numbers you can picture
- Three conditional tools, three different questions
- What competing calculators miss
- Frequently Asked Questions
- Add This Calculator to Your Website
- References
How to use this calculator: pick the mode that matches your numbers
Start from what you know, not from what you want. Each mode asks for a different set of knowns, and choosing the mode is most of the work.
| Mode | You know | You get |
|---|---|---|
| P(A|B) or P(B|A) | P(A), P(B), P(A and B) | The conditional probability in either direction |
| Bayes | P(B|A), P(A), P(B) | P(A|B), flipped from the reverse conditional |
| Counts | Both-count, B-count, grand total | P(A|B) from a frequency table, plus P(B) and P(A and B) |
| Joint (independence) | P(A), P(B) | P(A and B), valid only if the events are independent |
| Union | P(A), P(B), P(A and B) | P(A or B) with the overlap counted once |
| Independence test | P(A), P(B), P(A and B) | Whether P(A and B) equals P(A) x P(B) |
| Single event / Complement | Counts, or P(A) alone | P(A) from favorable over total, or P(not A) = 1 - P(A) |
Enter values as decimals (0.08) or switch the input toggle to percent (8) and the tool converts. In single-event mode the two fields become favorable outcomes and total outcomes, and in counts mode the probability fields give way to the three count fields. The calculator is pre-filled with the medical example worked through below, so pressing Calculate on the default mode shows 0.1125 immediately.
The formula: the same fraction, inside a smaller world
Conditioning restricts attention to the outcomes where B happened and asks what fraction of those also contain A. That sentence is the whole formula.
The definition is stated this way in standard references, for example the LibreTexts engineering statistics chapter on probability, and the denominator explains every edge case on this page. Divide by P(B) and a zero P(B) is fatal: you cannot condition on an event that never happens. It also explains the cap the tool enforces: P(A and B) counts outcomes inside both events, so it cannot be larger than P(B) itself, or than P(A). An input set that breaks the cap describes no possible pair of events, and the honest response is an error message, not a quotient.
Worked example: a positive test that still means 11.25%
One percent of patients have a condition (P(A) = 0.01). A test comes back positive for 8 percent of patients (P(B) = 0.08), and 0.9 percent of all patients both have the condition and test positive (P(A and B) = 0.009). A patient tests positive. What is the chance they have the condition?
| Path | Working | Result |
|---|---|---|
| Direct: P(A|B) | 0.009 / 0.08 | 0.1125 = 11.25% |
| Bayes: P(B|A) x P(A) / P(B) | 0.9 x 0.01 / 0.08 | 0.1125 = 11.25% |
| Reverse: P(B|A) from the joint | 0.009 / 0.01 | 0.9 = 90% |
The 90 percent figure is the one people quote, and it answers the reverse question: given the condition, how often is the test positive? The patient holding the result needs the other direction, and it is 11.25 percent, because the condition is rare and most positives come from the large healthy majority testing falsely positive. Confusing those two directions has a name in legal contexts, the prosecutor's fallacy, and it is the single most consequential error in applied probability. StatTrek's Bayes theorem lesson walks the same structure with a weather forecast: a 90 percent accurate rain prediction still leaves rain unlikely when rain itself is rare.
Counts mode: the same math with numbers you can picture
Probabilities hide the base rate; counts expose it. Switch to counts mode with the pre-filled clinic figures: 1,000 patients, 93 positive tests, 45 of those positives true cases. P(condition | positive) = 45 / 93 = 0.483871, or 48.39 percent, and the tool also reports P(positive) = 0.093 and P(condition and positive) = 0.045 for context.
Use counts whenever your data arrives as a table: survey cross-tabs, quality-control tallies, test results, win-loss records. The arithmetic is identical to the probability modes, but errors are visible. A joint probability of 0.009 looks abstract; "9 out of every 1,000 patients" does not, and a count that exceeds its own row total is obviously wrong in a way a decimal never is. For simple repeated trials with no conditioning, like a run of coin flips, the coin flip probability calculator covers the equally likely outcomes case directly.
Three conditional tools, three different questions
This page computes the probability of one event given another. Its two siblings answer the questions that come next once values and spreads matter.
The conditional expected value calculator computes E[X|C]: given the condition, what is the average outcome, when outcomes carry amounts like payoffs or claim sizes. The conditional variance calculator computes Var(X|C): given the condition, how spread out are those outcomes around that average. Probability first, then center, then spread. For combinations of independent events with no conditioning involved, the compound probability calculator handles the and/or chains.
What competing calculators miss
The conditional probability tools ranking for this term were reviewed in depth, including the strongest one.
Miss 1: no single-event or complement mode. The OnlyCalculators conditional tool is genuinely strong: it returns all four conditionals with complements and offers a Bayesian path. But ask it the two simplest questions in probability, favorable over total, or one minus P(A), and you need a different page. Both live here as modes, because simple questions deserve the same tool as hard ones.
Miss 2: sensitivity and specificity, or nothing. Several Bayes tools force the medical framing: enter prevalence, sensitivity and specificity, and the tool derives P(B) for you. That is convenient for one textbook setup and unusable when you already know P(B) directly, which is most non-medical problems. Bayes mode here takes P(B|A), P(A) and P(B) as they come, and checks the result cannot exceed 1.
Miss 3: silent acceptance of impossible inputs. Enter P(A and B) larger than P(B) into a typical tool and it divides happily, returning a conditional probability above 100 percent. Every mode here validates: probabilities bounded by 0 and 1, the joint capped at the smaller marginal, counts ordered so no part exceeds its whole. The error messages name the exact rule that was broken.
One honest limit: the Bayes mode needs P(B) given. Tools that derive P(B) from a false-positive rate are doing one extra step, the law of total probability, which this tool leaves to you: P(B) = P(B|A) x P(A) + P(B|not A) x P(not A). The counts mode sidesteps the issue entirely when you have raw tallies.
Frequently Asked Questions
They condition on different events. P(A|B) restricts to outcomes where B happened and asks how often A holds there; P(B|A) does the reverse. They are usually very different numbers: in the worked example P(condition | positive) is 11.25 percent while P(positive | condition) is 90 percent. Confusing them is called the prosecutor's fallacy.
When P(B) = 0. Conditioning means restricting to the cases where B happened, and if B never happens there are no cases to restrict to. The formula divides by P(B), so the calculator flags a zero denominator instead of returning a number.
Yes. Switch the input toggle to percent and type 8 for 8 percent. The tool converts to decimals internally and shows every answer as both a decimal and a percentage, so you can enter in the unit your source uses without converting by hand.
Whenever your data comes as raw numbers: test results, survey responses, contingency tables, inspection tallies. Counts make the base rate visible (45 true cases out of 93 positives) and make data errors obvious, because a part can never exceed its whole. The calculator converts to probabilities for you.
Check whether P(A and B) equals P(A) x P(B). The independence test mode does exactly this comparison and calls the events independent when the two agree within a small tolerance. Independence also means conditioning changes nothing: P(A|B) = P(A). The joint mode's multiplication shortcut is only valid when this test passes.
P(A or B) = P(A) + P(B) - P(A and B). Adding the two probabilities counts the outcomes where both events happen twice, once inside each event, so the overlap is subtracted back out once. For mutually exclusive events the joint probability is zero and the rule reduces to a plain sum.
Because both events happening is a subset of each event happening alone. The overlap of A and B sits inside A and inside B, so its probability cannot exceed either one. Inputs that break this describe no possible events, and any conditional probability computed from them would be meaningless.
It is the same relationship rearranged. P(A|B) mode divides a joint probability you supply. Bayes mode rebuilds that joint from the reverse conditional, P(A and B) = P(B|A) x P(A), then divides by P(B). Use whichever matches the numbers you actually know; with consistent inputs both modes return the same answer, as the worked example shows.
Add This Calculator to Your Website
References
- StatTrek, "Bayes Theorem" - the classic rain-forecast worked example of flipping a conditional probability, used as the cross-check pattern for the medical example here. StatTrek: Bayes Theorem. Accessed October 2026.
- LibreTexts, "Statistical Analysis of Data for Engineers, Chapter 2" - the formal definition P(A|B) = P(A and B) / P(B) and the independence condition used by the test mode. LibreTexts: Histograms, Statistical Measures and Probability. Accessed October 2026.
- LibreTexts, "Applied Probability: Conditional Expectation and Regression" - conditioning developed from joint distributions, the foundation the expected-value sibling tool builds on. LibreTexts: Conditional Expectation, Regression. Accessed October 2026.
- Technion, "Probability and Statistics: A Survival Guide" - joint, marginal and conditional distributions with the multiplication rule stated formally. Technion: Probability and Statistics Survival Guide. Accessed October 2026.
- University of Puerto Rico, "Conditional Expectation" course notes - conditional distributions built by renormalizing joint probabilities, the same operation the counts and joint modes perform. UPRM: Conditional Expectation Notes. Accessed October 2026.
