# Without Replacement

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

In [3]:
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[3]:
(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 [4]:
data_F = toy_dataset[(toy_dataset["Geography"] == "France")]
(data_F.shape[0])/(toy_dataset.shape[0])*(data_F.shape[0]-1)/(toy_dataset.shape[0]-1)

Out[4]:
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 [5]:
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[0]-1)+(data_K.shape[0]-1))/(toy_dataset.shape[0]-3)
(data_S.shape[0]/toy_dataset.shape[0])*(data_B.shape[0]/(toy_dataset.shape[0]-1))*(data_K.shape[0]/(toy_dataset.shape[0]-2))*(1-SBK)

Out[5]:
9.618221727095405e-08
In [ ]: