[PYTHON] [Statistics for programmers] Bayes' theorem

table of contents

Statistics for Programmers-Table of Contents

Premise

We recommend that you read the following articles in advance.

-What is an event -Conditional Probability and Multiplication Theorem

Bayes' theorem

Under the condition that event A occurs, the conditional probability when i-type event B occurs is calculated as follows. Event B of type K is defined as B_1, B_2, B_3 ... B_i, and they are excluded from each other.

The conditional probability that event Bi will occur under the condition that event A will occur is calculated by the following formula.

P(B_i|A) = \frac{P(A∩B_i)}{P(A)}

In the part of P (A∩B_i), Multiplication theorem(P(A∩B)=P(A)×P(A|B))Using,P(A)×P(A|B)Substitute. Then it will be replaced with the following formula.

P(B_i|A) = \frac{P(B_i) \cdot P(A|B_i)}{P(A)}

This is Bayes' theorem. Each variable has the following meaning.

variable Description
P(A) Probability of A occurring
P(B) Probability of B occurring (prior probability)
P(A|B) Probability of A occurring after B (conditional probability, likelihood)
P(B|A) Probability of B occurring after A (conditional probability, posterior probability)

Proof of Bayes' theorem

For details, please refer to Proof of Bayes' Theorem.

The probability that A will occur after B (conditional probability) × the probability that B will occur is Probability of B occurring after A (conditional probability) x same as probability of A occurring.

In other words

P(B_i|A) \cdot P(A) = P(A|B_i) \cdot P(B_i)

It means that. Dividing both sides of this by P (A) gives the following form.

P(B_i|A) = \frac{P(B_i) \cdot P(A|B_i)}{P(A)}

Expand Bayes' theorem

In addition, Bayes' theorem is often used in this way.

P(B_i|A) = \frac{P(B_i)\cdot P(A|B_i)}{\sum_{j=1}^{k}P(B_j)\cdot P(A|B_j)} 

reference

-Bayes' theorem -Proof of Bayes' theorem

Recommended Posts

[Statistics for programmers] Bayes' theorem
[Statistics for programmers] Box plot
[Statistics for programmers] Mean, median, mode
[Statistics for programmers] What is an event?
[Statistics for Programmers] Table of Contents-Data Science
[Statistics for programmers] Conditional probabilities and multiplication theorems
[Statistics for programmers] Lorenz curve and Gini coefficient
Program for studying statistics
[Statistics for programmers] Variance, standard deviation and coefficient of variation
4. Bayesian statistics in Python 1-1. Emotional judgment by naive Bayes [Bayes' theorem]
[Statistics for programmers] Random variables, probability distributions, and probability density functions
Prolog Object Orientation for Python Programmers
Movement statistics for time series forecasting