1. Two ways to get a column of another column with max/min values:
a. most_bars_country = flags["name"][flags["bars"].idxmax()]
b. bars_sorted = flags.sort_values("bars", ascending=[0])
most_bars_country = bars_sorted["name"].iloc[0]
2. The way to get the probability of a certain value in a column:
orange_probability = flags[flags["orange"]==1].shape[0]/flags.shape[0]
3. The way to calculate combination by using factorial:
import math
def find_outcome_combinations(N, k): # Calculate the numerator of our formula.
numerator = math.factorial(N) # Calculate the denominator.
denominator = math.factorial(k) * math.factorial(N - k) # Divide them to get the final value.
return numerator / denominator
4. The easier way to calculate the prabability of a number in a combination by using a library of scipy:
import scipy
from scipy import linspace
from scipy.stats import binom
outcome_counts = linspace(0,30,31) # Create a range of numbers from 0 to 30, with 31 elements (each number has one entry).
dist = binom.pmf(outcome_counts,30,0.39) # The list of probability of the combination.
plt.bar(outcome_counts,dist)
plt.show()
5. Sometimes we'll want to be able to tell people the expected value of a probability distribution -- the most likely result of a single sample that we look at.? To compute this, we just multiply N by p.
6. If we would like to calculate the probability of value k or less will occur, we can use cummulate density function:
outcome_counts = linspace(0,30,31)
dist = binom.cdf(outcome_counts,30,0.39) #To get cummulate density
plt.plot(outcome_counts,dist)
7.