How to do it...

Let’s explore the beta distribution through the following steps:

  1. Import PyTorch and matplotlib because we will visualize the shape of the distributions:
>>> import torch>>> import matplotlib.pyplot as plt
  1. We start by visualizing the shape of the beta distribution with the starting positions, α=1 and β=1:
>>> beta1 = torch.distributions.beta.Beta(1, 1)>>> samples1 = [beta1.sample() for _ in range(100000)]>>> plt.hist(samples1, range=[0, 1], bins=10)>>> plt.title(‘beta(1, 1)’)>>> plt.show()

You will see the following plot:

Obviously, when α=1 and β=1, it doesn't provide any information about where the true value lies in the ...

Get PyTorch 1.x Reinforcement Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.