Learn practical skills, build real-world projects, and advance your career

PyTorch and Distributions Stats

Exploring different statistics distributions using pytorch

An short introduction about PyTorch and about the chosen functions.

  • Bernoulli
  • Binomial
  • Geometric
  • Normal
  • OneHotCategorical
# Import torch and other required modules
import torch

Function 1 - torch.distributions.Bernoulli

The Bernoulli distribution in statistics indicate the same probability of all tentatives of success.

In below Exemple 1, we have set the 70% probability of result be 1 and 30% be zero

# Example 1 - working (change this)
prob = torch.distributions.Bernoulli(torch.tensor([0.70]))
prob.sample()
tensor([1.])

We can use for to try 10 samples