Statistical Rethinking with PyMC#
Welcome to the Statistical Rethinking with PyMC interactive textbook companion! This resource brings Richard McElreathβs exceptional Statistical Rethinking course to Python developers.
π About This Project#
Statistical Rethinking is an incredible resource for learning Bayesian Statistics, written by Richard McElreath, Full Professor of Anthropology at the Max Planck Institute for Evolutionary Anthropology.
What Makes This Different#
The original textbook uses R and Stan for its code examples. The core PyMC development team created Python ports of these examples, and weβve taken it one step further:
β¨ Each notebook includes comprehensive summaries of the textbook material alongside the Python code, eliminating the need to constantly switch between the book and notebooks.
This approach makes Statistical Rethinking accessible to anyone proficient in Python, reducing friction and making your learning journey as seamless as possible.
π― What Youβll Learn#
Bayesian Thinking: Build intuition for probabilistic reasoning
PyMC Modeling: Hands-on experience with modern Bayesian tools
Causal Inference: Understand DAGs and causal relationships
Practical Skills: Apply these techniques to real-world data
π How to Use This Book#
Online Reading#
Navigate through chapters using the sidebar. Each chapter includes:
π Detailed explanations of statistical concepts
π» Python/PyMC code implementations
π Visualizations and examples
π Exercises to test your understanding
Interactive Coding#
Every notebook can be opened in Google Colab! Just click the Colab button at the top of any chapter to:
Run code interactively
Modify examples
Experiment with your own data
Local Development#
Clone the repository to work offline:
git clone https://github.com/vanislekahuna/Statistical-Rethinking-PyMC.git
cd Statistical-Rethinking-PyMC
π Prerequisites#
To get the most from this material:
Python: Basic understanding of Python syntax
NumPy/Pandas: Familiarity with these libraries is helpful
Statistics: Some exposure helpful, but Bayesian knowledge not required!
Curiosity: A genuine interest in understanding data through a Bayesian lens
πΊοΈ Course Structure#
The book follows Richard McElreathβs textbook structure:
Part I: Foundations
Chapters 1-3: Bayesian basics and sampling
Chapter 4: Linear models
Part II: Linear Models
Chapters 5-8: Multiple regression, causality, interactions
Part III: Generalized Linear Models
Chapters 9-11: MCMC, maximum entropy, count data
Part IV: Advanced Topics
Chapters 12-17: Multilevel models, measurement error, missing data
π¬ Getting Started#
Ready to begin your Bayesian journey? Head to Chapter 1: The Golem of Prague to start learning!
π Acknowledgments#
This work builds upon:
Richard McElreath: For the incredible original textbook and course
PyMC Team: For porting the R/Stan code to Python
Community Contributors: Everyone who has helped improve these materials
π Reference#
McElreath, R. (2020). Statistical Rethinking: A Bayesian Course with Examples in R and Stan (2nd ed.). CRC Press.
π Additional Resources#
Questions or feedback? Open an issue on our GitHub repository