# Without Replacement

Last updated: September 5th, 2020
In :
import pandas as pd
import numpy as np

In :
toy_dataset_2 = pd.read_csv('Churn Modeling.csv')
desired_columns = ["CustomerId", "Surname", "Geography", "Gender", "Age"]
toy_dataset_1 = toy_dataset_2[desired_columns]
toy_dataset = toy_dataset_1[1:500]
toy_dataset.shape

Out:
(499, 5)

This is a dataset which contain some customers

Two person are randomly chosen without replacement, what is the probability of both are French?

In :
data_F = toy_dataset[(toy_dataset["Geography"] == "France")]
(data_F.shape)/(toy_dataset.shape)*(data_F.shape-1)/(toy_dataset.shape-1)

Out:
0.21566023613492047

exercise: Four person are randomly chosen without replacement, what is the probability of the first has as surname Shih, the second Burns, the third Kennedy and the fourth has a different surname that all the above?

In [ ]:


In :
data_S = toy_dataset[(toy_dataset["Surname"] == "Shih")]
data_B = toy_dataset[(toy_dataset["Surname"] == "Burns")]
data_K = toy_dataset[(toy_dataset["Surname"] == "Kennedy")]
SBK = ((data_S.shape-1)+(data_K.shape-1))/(toy_dataset.shape-3)
(data_S.shape/toy_dataset.shape)*(data_B.shape/(toy_dataset.shape-1))*(data_K.shape/(toy_dataset.shape-2))*(1-SBK)

Out:
9.618221727095405e-08
In [ ]: