1. Concepts & Definitions
1.1. Example of random variables
1.2. Probability of events to random variables
1.4. Discrete uniform distribution of probability
1.5. Bernoulli distribution of probability
1.6. Binomial distribution of probability
1.7. Hypergeometrical distribution of probability
2. Problem & Solution
It is possible to illustrate the possible results from the first experiment with the next Figure. This figure contains a tree graph that shows the connection between joint probability and the number of heads in the experiment of throwing three times a coin. The probability of Head (H) or Tail (T) face events are equal and independent events: P(H) = P(T) = 0.5, and P(H|T) = P(H) or P(T|H) = P(T).
From the previous Figure, it is possible to create the next table relating the number of times a head could appear and its corresponding probability.
From this first experiment, it emerges the necessity to define the probability distribution of a random variable which is done next.
Displays all possible values that a variable random can assume, as well as their probabilities correspondents.
The next computational code shows how to compute the probability of the previous example and shows its distribution bar plot.
import pandas as pd
ph = 0.5
pt = 1-ph
p3 = ph*ph*ph
p2 = 3*ph*ph*pt
p1 = 3*ph*pt*pt
p0 = pt*pt*pt
data = [p0, p1, p2, p3]
rows = ['p']
cols = [0, 1, 2, 3]
df = pd.DataFrame(data=[data], index=rows, columns=cols)
df
df.loc['p',:].plot.bar()
The previous complete code is available in the following link:
https://colab.research.google.com/drive/1d0RFkpNTTLwauI1eff-AqG9hutAeTwpg?usp=sharing