0.01
Low commit activity in last 3 years
No release in over a year
Ruby code translations and additional material for the book "Statistical Rethinking" of Richard McElreath
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

rubythinking

Let's do the Statistical Rethinking journey in Ruby!

Links to compiled web versions of the notebooks

Chapter 2

Chapter 3

Ruby ported code snippets from the chapters

FAQ

Q: What is the purpose of this?

The book "Statistical Rethinking" by Richard McElreath is a famous textbook to learn Bayesian Statistics. There is a variety of additional material on the internet available for Python, R and probably other programming languages.

This repository offers some material of following the book and its excercises in Ruby. On the one hand, this repository offers Ruby-based Jupyter notebooks using iruby, on the other hand it is packaged as Ruby gem to easily install some dependencies like charting libraries to run the notebooks.

Q: Which version of the book are you using?

The second edition!

Q: You are often using this in Ruby based notebooks. Can use it without them?

Sure. Just install the gem and play with it in any other Ruby environment you use!

Q: I'm new to Ruby but want to run your Ruby based notebooks. What should I do?

First: You need to have Jupyter installed on your machine! Check https://jupyter.org/install for installation information!

The structure of this repository forms a Ruby gem. But before you can install it, you need to make sure iruby is working on your machine. In case of doubt, check latest iruby documentation!

Then you just do

gem install rubythinking && iruby register --force

After this, you have installed this little Ruby gem and told iruby kernel to take it into account. Now you can start a Jupyter notebook and inspect the jupyter notebooks in the /notebooks folder of this repository. To do so, download the repo, cd into the directory and

jupyter notebook

By installing the gem, some other dependency gems will get installed for you that are convenient helpers in the notebooks.

If you are creating a new Jupyter notebook with iruby, then you can load all code used by rubythinking with

require "rubythinking"
include Rubythinking

dbinom(6, prob: 0.5, size: 9) # => 0.1640625
rbinom(10, prob: 0.5, size: 5) # => [2, 2, 1, 0, 4, 1, 3, 1, 3, 1]

Q: Can I participate?

I'd appreciate this very much! ☀️ This project is very incomplete and there are tons of excercises and snippets of the book that await being ported to Ruby by someone. Unfortunately, I can only do it from time to time and I'd love having people joining this initiative.

If you are interested, feel free to pick up any part of the book you are interested in, try replicating or adopting it with Ruby and then either support an iruby notebook to the notebooks folder or anything else you like to this repository. Supplementary Ruby code can go somewhere in the the lib folder.

Even tiny contributions are rewarded with extra positive karma 😉