Probability calculator (events & Bayes' theorem)

Calculate P(A or B), P(A and B) and P(A | B) for two events, or apply Bayes' theorem to a test result, with a probability tree and Venn diagram.

Diperbarui Contoh terverifikasi: 6

How likely A is before seeing the evidence, e.g. how common a condition is.
Chance of seeing the evidence when A is true, e.g. a test's sensitivity.
Chance of seeing the evidence when A is false, e.g. the false-positive rate (1 − specificity).
Coba
P(A | B)
P(A | B): 0.091743
Tempat desimal maksimum: 6; Terdekat, jika berjarak sama menjauhi nol
P(A and B)
0.009
P(A or B)
0.0991
P(B)
0.0981
P(A | not B)
0.001109
P(not A)
0.99
P(not B)
0.9019
P(neither A nor B)
0.9009
P(exactly one of A, B)
0.0901
Independent?
No

After seeing B, the probability of A moves from 1% to 9.17%. In natural frequencies: of 10,000 cases, about 90 have A and show B, while 891 show B without A — so only 90 of the 981 who show B actually have A.

Probability tree

0.010.99Anot A0.90.10.090.91A and B: 0.009A and not B: 0.001not A and B: 0.0891not A, not B: 0.9009
Cara menghitung S
  1. Total probability of the evidence

    P(B)=P(B∣A)P(A)+P(B∣Aˉ)P(Aˉ)=0.9×0.01+0.09×0.99=0.0981P(B) = P(B \mid A)P(A) + P(B \mid \bar A)P(\bar A) = 0.9 \times 0.01 + 0.09 \times 0.99 = 0.0981
  2. Bayes' theorem

    P(A∣B)=P(B∣A)P(A)P(B)=0.0090.0981=0.091743P(A \mid B) = \frac{P(B \mid A)P(A)}{P(B)} = \frac{0.009}{0.0981} = 0.091743
  3. Addition rule

    P(A∪B)=P(A)+P(B)−P(A∩B)=0.01+0.0981−0.009=0.0991P(A \cup B) = P(A) + P(B) - P(A \cap B) = 0.01 + 0.0981 - 0.009 = 0.0991
  4. Complements

    P(Aˉ)=0.99,P(Bˉ)=0.9019,P(A∪B‾)=0.9009P(\bar A) = 0.99,\quad P(\bar B) = 0.9019,\quad P(\overline{A \cup B}) = 0.9009
  5. Independence check

    P(A)P(B)=0.000981≠P(A∩B)=0.009P(A)P(B) = 0.000981 \ne P(A \cap B) = 0.009

Tentang Probability calculator (events & Bayes' theorem)

For two events A and B, the addition rule gives P(A or B) = P(A) + P(B) − P(A and B), the multiplication rule gives P(A and B) = P(A) × P(B | A), and conditional probability is P(A | B) = P(A and B) / P(B). Bayes' theorem mode runs the conditional the other way: from a prior P(A) and the two evidence rates P(B | A) and P(B | not A), it returns the updated probability P(A | B).

The Bayes default is a screening test for a condition with 1% prevalence, 90% sensitivity and a 9% false-positive rate. A positive result raises the probability from 1% to 9.17%, because in 10,000 people the 90 true positives are outnumbered by 891 false positives.

Enter probabilities from 0 to 1; fractions such as 1/6 are accepted. Two-events mode rejects combinations that cannot exist, such as a P(A and B) larger than P(A) or P(B).

Contoh penyelesaian

Screening test: 1% prevalence, 90% sensitivity, 9% false positives

Calculate
Bayes' theorem
Prior probability P(A)
0.01
P(B | A)
0.9
P(B | not A)
0.09
P(A | B)
0.091743
P(B)
0.0981

Sumber pemeriksaan: Gigerenzer et al. (2007) mammography example (about 1 in 10 positives has the disease); exact 0.009/0.0981 = 10/109 with Python fractions

Independent events 0.5 and 0.4

Calculate
Two events
P(A)
0.5
P(B)
0.4
How A and B relate
Independent
P(A and B)
0.2
P(A or B)
0.7
P(A | B)
0.5
P(neither A nor B)
0.3
Independent?
Yes

Sumber pemeriksaan: P(A)P(B) = 0.2; addition rule 0.5 + 0.4 − 0.2

Mutually exclusive 0.3 and 0.45

Calculate
Two events
P(A)
0.3
P(B)
0.45
How A and B relate
Mutually exclusive
P(A and B)
0
P(A or B)
0.75
P(A | B)
0
P(exactly one of A, B)
0.75
Independent?
No

Sumber pemeriksaan: Definition: P(A ∩ B) = 0; union is the plain sum

Known joint probability

Calculate
Two events
P(A)
0.6
P(B)
0.5
How A and B relate
I know P(A and B)
P(A and B)
0.4
P(A or B)
0.7
P(A | B)
0.8
P(B | A)
0.666667
P(neither A nor B)
0.3
P(exactly one of A, B)
0.3
Independent?
No

Sumber pemeriksaan: Hand calculation with Python fractions: 0.4/0.5, 0.4/0.6 = 2/3, 1 − 0.7

Pertanyaan

How do you calculate the probability of A or B?

Add the two probabilities and subtract the overlap: P(A or B) = P(A) + P(B) − P(A and B). For independent events with P(A) = 0.5 and P(B) = 0.4, the overlap is 0.5 × 0.4 = 0.2, so P(A or B) = 0.7. For mutually exclusive events the overlap is 0, so the probabilities simply add: 0.3 + 0.45 = 0.75.

What is the difference between independent and mutually exclusive events?

Independent events don't affect each other's chances, so P(A and B) = P(A) × P(B). Mutually exclusive events can't happen together, so P(A and B) = 0. Two events with non-zero probabilities can't be both: if A rules out B, knowing A happened changes the chance of B to 0. Two coin flips are independent; heads and tails on one flip are mutually exclusive.

Why does a positive result on an accurate test often mean you probably don't have the condition?

Because false positives from the large healthy group can outnumber true positives from the small affected group. With 1% prevalence, 90% sensitivity and 9% false positives, only 9.17% of positives are true. At 10% prevalence the same test gives 0.09 / (0.09 + 0.081) = 52.6%. This probability is the test's positive predictive value, and it depends on prevalence as much as on accuracy.

How do you calculate the probability of at least one event happening?

Subtract the chance that it never happens from 1: P(at least one) = 1 − (1 − p)ⁿ for n independent tries with probability p each. The chance of at least one six in 4 rolls of a die is 1 − (5/6)⁴ = 671/1296, about 0.5177, just above even odds. With p = 0.01 you need 69 tries before the chance passes 50%.

Seberapa akurat “Probability calculator (events & Bayes' theorem)”?

Akurasi bergantung pada masukan dan asumsi metode. Aritmetika desimal memakai 50 digit signifikan, tetapi perkiraan, metode numerik dan data sumber bisa kurang presisi; pembulatan yang ditampilkan tidak menghilangkan batasan itu. Contoh penyelesaian yang diperiksa dengan sumber independen: 6. Misalnya, “Screening test: 1% prevalence, 90% sensitivity, 9% false positives” diperiksa dengan Gigerenzer et al. (2007) mammography example (about 1 in 10 positives has the disease); exact 0.009/0.0981 = 10/109 with Python fractions.

Dari mana metode ini berasal?

Grinstead & Snell, Introduction to Probability (AMS), §4.1 Discrete conditional probability and Bayes' formula; Gigerenzer et al. (2007). Helping doctors and patients make sense of health statistics. Psychological Science in the Public Interest 8(2), 53–96.

Tentang kalkulator ini

P(A∣B)=P(B∣A) P(A)P(B∣A)P(A)+P(B∣Aˉ)P(Aˉ),P(A∪B)=P(A)+P(B)−P(A∩B)P(A \mid B) = \frac{P(B \mid A)\,P(A)}{P(B \mid A)P(A) + P(B \mid \bar A)P(\bar A)},\qquad P(A \cup B) = P(A) + P(B) - P(A \cap B)

Sumber

  1. Grinstead & Snell, Introduction to Probability (AMS), §4.1 Discrete conditional probability and Bayes' formula
  2. Gigerenzer et al. (2007). Helping doctors and patients make sense of health statistics. Psychological Science in the Public Interest 8(2), 53–96

Diperiksa dengan referensi

Kalkulator ini mencakup 6 contoh perhitungan dengan jawaban dari sumber independen. Contoh tersebut dijalankan dalam rangkaian pengujian dan dapat Anda jalankan di sini juga.

Kalkulator terkait