CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers

Type Error in the First Coin Flipping Algorithm in Chapter 1

Opened this issue · 1 comments

In Chapter 1 (Ch1_Introduction_PyMC2.ipynb) there's a type error in the first coin flipping algorithm (Example: Mandatory coin-flip example) at line:
sx = plt.subplot(len(n_trials) / 2, 2, k + 1) inside the for-cycle.
The operation len(n_trials) / 2 gives back a float and not an integer (at least in the current version of Colab).

It can be fixed by adding int():
sx = plt.subplot(int(len(n_trials) / 2), 2, k + 1)

Edit:
Or more simply with len(n_trials) // 2 as Lucian Sasu suggested:
sx = plt.subplot(len(n_trials) // 2, 2, k + 1)

... Or use len(n_trials // 2) instead of cast to int.