02 Valid discrete probability distribution examples#

%%html
<iframe width="700" height="400" src="https://www.youtube.com/embed/uXtxKxYl1Iw/" frameborder="0" allowfullscreen></iframe>
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import matplotlib.pyplot as plt
import seaborn as sns

khanacademy

Valid discrete probability distribution examples fig 1Valid discrete probability distribution examples fig 2

basketball_df = DataFrame({'Outcome': ['Miss both free throws', 'Make exactly one free throw', 'Make both free throws'],
          'Probabilty': [0.2, 0.5, 0.1]}).set_index('Outcome')
basketball_df
Probabilty
Outcome
Miss both free throws 0.2
Make exactly one free throw 0.5
Make both free throws 0.1
basketball_df['Probabilty'].sum() == 1
False
creatures_df = DataFrame({'Type of Earth Creature': ['Chickens', 'Cows', 'Humans'], '#': [97, 47, 77]}).set_index('Type of Earth Creature')
creatures_df
#
Type of Earth Creature
Chickens 97
Cows 47
Humans 77
creatures_df['Estimated Probabilty'] = creatures_df['#'] / creatures_df['#'].sum()
creatures_df = creatures_df[['Estimated Probabilty']]
creatures_df
Estimated Probabilty
Type of Earth Creature
Chickens 0.438914
Cows 0.212670
Humans 0.348416
creatures_df['Estimated Probabilty'].sum() == 1
True