Probabilistic-Programming-and-Bayesian-Methods-for-Hackers icon indicating copy to clipboard operation
Probabilistic-Programming-and-Bayesian-Methods-for-Hackers copied to clipboard

Type Error in the First Coin Flipping Algorithm in Chapter 1

Open lorenzo8612 opened this issue 3 months ago • 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)

lorenzo8612 avatar Aug 31 '25 19:08 lorenzo8612