{"success":true,"version":"v1","request":{"tool":"get_calculator_schema","calculator_id":"bayes-theorem"},"result":{"entity_type":"calculator","id":"bayes-theorem","calculator_id":"bayes-theorem","canonical_url":"https://tttkmbb.com/statistics/bayes-theorem","name":"Bayes' Theorem Calculator","title":"Bayes' Theorem Calculator – Posterior Probability P(A|B) from Prior and Likelihoods","category":"statistics","category_name":"Statistics & Probability","tool_name":"calculate_bayes_posterior_probability","featured_mcp_tool":false,"description":"Applies Bayes' theorem to a prior probability P(A) and the likelihoods P(B|A) and P(B|not A) to obtain the posterior P(A|B), the marginal P(B), the complementary posteriors and the likelihood ratio (Bayes factor).","use_when":"You know how likely an evidence B is under a hypothesis A and under its negation and want the updated probability of A after observing B (test results, spam filtering, diagnosis, fault detection).","do_not_use_when":"The inputs are sensitivity, specificity and prevalence in percent and you want predictive values per 1000 people (use diagnostic-test), or the events are simply independent (use probability-of-events).","inputs":[{"name":"probability_a","label":"Prior P(A)","type":"number","required":true,"exclusive_min":0,"exclusive_max":1,"description":"Prior probability of the hypothesis A, as a fraction between 0 and 1.","example":0.005},{"name":"probability_b_given_a","label":"P(B | A)","type":"number","required":true,"min":0,"max":1,"description":"Probability of observing the evidence B when A is true (e.g. sensitivity as a fraction).","example":0.99},{"name":"probability_b_given_not_a","label":"P(B | not A)","type":"number","required":true,"min":0,"max":1,"description":"Probability of observing B when A is false (e.g. false-positive rate = 1 − specificity).","example":0.01}],"outputs":[{"name":"probability_a_given_b","label":"Posterior P(A | B)","type":"number","decimals":6,"description":"Probability of A after observing B."},{"name":"probability_b","label":"P(B)","type":"number","decimals":6,"description":"Marginal probability of the evidence: P(B|A)·P(A) + P(B|¬A)·(1 − P(A))."},{"name":"probability_not_a_given_b","label":"P(not A | B)","type":"number","decimals":6,"description":"1 − P(A|B)."},{"name":"probability_a_given_not_b","label":"P(A | not B)","type":"number","decimals":6,"description":"Probability of A when B is not observed (omitted when P(B) = 1)."},{"name":"likelihood_ratio","label":"Likelihood ratio (Bayes factor)","type":"number","decimals":4,"description":"P(B|A) / P(B|¬A): how much B favours A (omitted when P(B|¬A) = 0)."},{"name":"prior_odds","label":"Prior odds","type":"number","decimals":6,"description":"P(A) / (1 − P(A))."},{"name":"posterior_odds","label":"Posterior odds","type":"number","decimals":6,"description":"prior_odds × likelihood_ratio = P(A|B) / P(¬A|B) (omitted when P(A|B) = 1)."}],"input_schema":{"type":"object","properties":{"probability_a":{"description":"Prior probability of the hypothesis A, as a fraction between 0 and 1.","type":"number","exclusiveMinimum":0,"exclusiveMaximum":1,"examples":[0.005]},"probability_b_given_a":{"description":"Probability of observing the evidence B when A is true (e.g. sensitivity as a fraction).","type":"number","minimum":0,"maximum":1,"examples":[0.99]},"probability_b_given_not_a":{"description":"Probability of observing B when A is false (e.g. false-positive rate = 1 − specificity).","type":"number","minimum":0,"maximum":1,"examples":[0.01]}},"additionalProperties":false,"required":["probability_a","probability_b_given_a","probability_b_given_not_a"]},"output_schema":{"type":"object","properties":{"probability_a_given_b":{"description":"Probability of A after observing B.","type":"number"},"probability_b":{"description":"Marginal probability of the evidence: P(B|A)·P(A) + P(B|¬A)·(1 − P(A)).","type":"number"},"probability_not_a_given_b":{"description":"1 − P(A|B).","type":"number"},"probability_a_given_not_b":{"description":"Probability of A when B is not observed (omitted when P(B) = 1).","type":"number"},"likelihood_ratio":{"description":"P(B|A) / P(B|¬A): how much B favours A (omitted when P(B|¬A) = 0).","type":"number"},"prior_odds":{"description":"P(A) / (1 − P(A)).","type":"number"},"posterior_odds":{"description":"prior_odds × likelihood_ratio = P(A|B) / P(¬A|B) (omitted when P(A|B) = 1).","type":"number"}}},"formula":"P(A|B) = P(B|A)·P(A) / P(B), with P(B) = P(B|A)·P(A) + P(B|¬A)·(1 − P(A)); P(A|¬B) = (1 − P(B|A))·P(A) / (1 − P(B)); odds form: posterior odds = prior odds × P(B|A)/P(B|¬A)","sources":[{"name":"Wikipedia – Bayes' theorem","url":"https://en.wikipedia.org/wiki/Bayes%27_theorem","type":"reference","retrieved_at":"2026-09-24"},{"name":"Wolfram MathWorld – Bayes' Theorem","url":"https://mathworld.wolfram.com/BayesTheorem.html","type":"reference","retrieved_at":"2026-09-24"}],"freshness":{"type":"static","max_age_seconds":null,"note":"Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output."},"examples":[{"name":"Drug test: 0.5 % prevalence, 99 % sensitivity, 1 % false positives (Wikipedia)","inputs":{"probability_a":0.005,"probability_b_given_a":0.99,"probability_b_given_not_a":0.01},"expected":{"probability_a_given_b":0.332215,"probability_b":0.0149,"probability_not_a_given_b":0.667785,"probability_a_given_not_b":0.000051,"likelihood_ratio":99,"prior_odds":0.005025,"posterior_odds":0.497487},"url":"https://tttkmbb.com/api/v1/calculate/bayes-theorem?probability_a=0.005&probability_b_given_a=0.99&probability_b_given_not_a=0.01"},{"name":"P(A) = 0.3, P(B|A) = 0.8, P(B|not A) = 0.2","inputs":{"probability_a":0.3,"probability_b_given_a":0.8,"probability_b_given_not_a":0.2},"expected":{"probability_a_given_b":0.631579,"probability_b":0.38,"probability_a_given_not_b":0.096774,"likelihood_ratio":4,"prior_odds":0.428571,"posterior_odds":1.714286},"url":"https://tttkmbb.com/api/v1/calculate/bayes-theorem?probability_a=0.3&probability_b_given_a=0.8&probability_b_given_not_a=0.2"}],"faq":[{"q":"Why is the posterior so low with a 99 % accurate test?","a":"When A is rare, the many false positives among the non-A majority outnumber the true positives: with 0.5 % prevalence about two thirds of positive results are false. This is the base-rate effect."},{"q":"Can I enter percentages?","a":"No, all inputs are probabilities between 0 and 1 (0.05 for 5 %). The diagnostic-test calculator accepts percentages."}],"tags":["bayes theorem","conditional probability","posterior probability","bayesian update","base rate"],"related":[{"calculator_id":"diagnostic-test","reason":"The same update expressed as sensitivity, specificity and predictive values."},{"calculator_id":"probability-of-events","reason":"Combine probabilities of independent or exclusive events."}],"links":{"html":"https://tttkmbb.com/statistics/bayes-theorem","markdown":"https://tttkmbb.com/statistics/bayes-theorem.md","json":"https://tttkmbb.com/statistics/bayes-theorem.json","api":"https://tttkmbb.com/api/v1/calculate/bayes-theorem","schema":"https://tttkmbb.com/api/v1/calculators/bayes-theorem","openapi":"https://tttkmbb.com/openapi.json","mcp":"https://tttkmbb.com/mcp"},"version":"v1","updated_at":"2026-09-24"},"timestamp":"2026-09-24T01:47:03Z","next_actions":[{"tool":"run_calculator","calculator_id":"bayes-theorem","reason":"Run Bayes' Theorem Calculator with the inputs above."}],"links":{"markdown":"https://tttkmbb.com/statistics/bayes-theorem.md"}}