# Packages list
library(knitr)

Part I

Experiment 1: picking up a marble from a bag filled with color marbles but half of them are hollow. The colors and marble counts are, 8 green, 8 red, 8 blue, 8 yellow.

Picking up a marble will be independent if there is replacement after the selection and will be dependent if there is no replacement after selection

The sample space will be each individual marble {HG,HG,HG,HG,G,G,G,G,HR,HR,HR,HR,R,R,R,R,HB,HB,HB,HB,B,B,B,B,HY,HY,HY,HY,Y,Y,Y,Y}

- Mutually exclusive event: taking out green and yellow marble. Since we are picking only 1 marble at a time, both events cannot happen at the same time.

-Not mutually exclusive event: taking out a green and hollow marble. Since picking a green and hollow marble can happen at the same time, we say that the event is non-mutually exclusive.

Experiment 2: Authorizing people for a loan based on their credit score.

There are 2 events happening here, the first one is running a credit score (300-850) and the other one is giving a yes or no to the applicant. Applications are approved to people with a credit score higher than 600

These are dependent events because the outcome of the credit score affects the outcome of the application. It would be an independent event if the outcome of the application is not determined by the credit score.

-Mutually exclusive event: a person with a 300 and 800 credit score. Credit score is a unique value, a person cannot have 2 different credit scores at a certain instant in time.

-Non mutually exclusive event: a person with a 700 credit score and approved application. This is a non-mutually exclusive event because these events can happen at the same time.

Part II

dt <- read.csv(file = "train.csv", 
               header = TRUE)
table(dt$Survived,
      dt$Sex, 
      dt$Pclass)
## , ,  = 1
## 
##    
##     female male
##   0      3   77
##   1     91   45
## 
## , ,  = 2
## 
##    
##     female male
##   0      6   91
##   1     70   17
## 
## , ,  = 3
## 
##    
##     female male
##   0     72  300
##   1     72   47