Difference between revisions of "Bayes' Theorem"

From Bitnami MediaWiki
Jump to navigation Jump to search
 
(15 intermediate revisions by 4 users not shown)
Line 7: Line 7:
 
::<math>P(A|B) = \dfrac{P(A\cap B)}{P(B)}</math> where <math>P(A\cap B)</math> is the '''joint probability''' that both A and B are true
 
::<math>P(A|B) = \dfrac{P(A\cap B)}{P(B)}</math> where <math>P(A\cap B)</math> is the '''joint probability''' that both A and B are true
 
::<math>P(A\cap B) = P(A|B)\,P(B) = P(B|A)\,P(A)</math>
 
::<math>P(A\cap B) = P(A|B)\,P(B) = P(B|A)\,P(A)</math>
 +
 +
In other terminology (VanderPlas):
 +
* <math>P(A|B)</math> is the '''posterior''', the probability of the model parameters given the data
 +
* <math> P(B|A)</math> is the '''likelihood'''
 +
* <math> P(A) </math> is the '''model prior''', which encodes knowledge about the model ''before'' considering the data <math>B</math>
 +
* <math> P(B) </math> is the '''model evidence''' (which in practice is a normalization term).
  
 
===Resources===
 
===Resources===
 
* The [https://towardsdatascience.com/bayesian-inference-and-markov-chain-monte-carlo-sampling-in-python-bada1beabca7 coin factory] problem
 
* The [https://towardsdatascience.com/bayesian-inference-and-markov-chain-monte-carlo-sampling-in-python-bada1beabca7 coin factory] problem
 
* Jake VanderPlas's [http://jakevdp.github.io/blog/2014/03/11/frequentism-and-bayesianism-a-practical-intro/ 5 part series] on github
 
* Jake VanderPlas's [http://jakevdp.github.io/blog/2014/03/11/frequentism-and-bayesianism-a-practical-intro/ 5 part series] on github
 +
* [https://nbviewer.org/github/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter1_Introduction/Ch1_Introduction_PyMC2.ipynb Bayesian Methods for Hackers] ported to PyMC3 and Python 3
 +
* ArviZ documentation on working with [https://python.arviz.org/en/0.14.0/getting_started/WorkingWithInferenceData.html inference data]
 +
* [https://github.com/pymc-devs/pymc-resources/tree/main/BDA3 Bayesian Data Analysis with Python and PyMC] by Gelman et al. (Code ported to Python)
 +
* [https://bayesiancomputationbook.com/markdown/chp_01.htmlBayesian Modeling and Computation in Python] by Martin, Kumar & Lao  (ported to Python]
 +
* [https://github.com/JWarmenhoven/DBDA-python Doing Bayesian Data Analysis] by John Kruschke, ported to Python
 +
* [https://github.com/pymc-devs/pymc-resources/tree/main/BDA3 Bayesian Data Analysis, 3ed] by Gelman et al, ported to Python
 +
* [https://ethanweed.github.io/pythonbook/landingpage.html Learn Statistics with Python] by Ethan Weed (refitting of "Learn Stats with R")
 +
* Jim Frost's [https://statisticsbyjim.com/basics/ Statistics by Jim]
 +
* NIST [https://www.itl.nist.gov/div898/handbook/eda/eda.htm Exploratory Data Analysis] pages
 +
 +
===Misc===
 +
* Python virtual environment [https://realpython.com/python-virtual-environments-a-primer/#what-is-a-python-virtual-environment primer]
 +
* NBShare notebook on [https://www.nbshare.io/notebook/512285365/PyTorch-Tutorial-A-Complete-Use-Case-Example/ PyTorch] (MNIST example)
 +
* Highlight data points and text in [https://cmdlinetips.com/2019/11/how-to-highlight-data-points-with-colors-and-text-in-python/ Python charts]
 +
* RevBayes (a package for phylogenetic analysis, with some good MCMC [https://revbayes.github.io/tutorials/ tutorial] pages
 +
* [https://www.pymc-labs.io/blog-posts/the-quickest-migration-guide-ever-from-pymc3-to-pymc-v40/ Migration] guide for PyMC 3 to 4
 +
* Conversion of R statistical functions to [https://github.com/tirthajyoti/Stats-Maths-with-Python/blob/master/R_Functions.py Python]
 +
* [https://towardsdatascience.com/8-commonly-used-pandas-display-options-you-should-know-a832365efa95 Pandas] display options cheatsheet

Latest revision as of 23:11, 28 February 2023

In case you forgot:

[math]\displaystyle{ P(A|B) = \dfrac{P(B|A)\,P(A)}{P(B)} }[/math]

where,

  • [math]\displaystyle{ P(A|B) }[/math] is the conditional probability that A is true given B
  • [math]\displaystyle{ P(A), P(B) }[/math] are the marginal probabilities that A or B is true

It's true by the definition of conditional probability:

[math]\displaystyle{ P(A|B) = \dfrac{P(A\cap B)}{P(B)} }[/math] where [math]\displaystyle{ P(A\cap B) }[/math] is the joint probability that both A and B are true
[math]\displaystyle{ P(A\cap B) = P(A|B)\,P(B) = P(B|A)\,P(A) }[/math]

In other terminology (VanderPlas):

  • [math]\displaystyle{ P(A|B) }[/math] is the posterior, the probability of the model parameters given the data
  • [math]\displaystyle{ P(B|A) }[/math] is the likelihood
  • [math]\displaystyle{ P(A) }[/math] is the model prior, which encodes knowledge about the model before considering the data [math]\displaystyle{ B }[/math]
  • [math]\displaystyle{ P(B) }[/math] is the model evidence (which in practice is a normalization term).

Resources[edit]

Misc[edit]

  • Python virtual environment primer
  • NBShare notebook on PyTorch (MNIST example)
  • Highlight data points and text in Python charts
  • RevBayes (a package for phylogenetic analysis, with some good MCMC tutorial pages
  • Migration guide for PyMC 3 to 4
  • Conversion of R statistical functions to Python
  • Pandas display options cheatsheet