Definitions
Independence: An event is independent when its probability of occuring is not incfluenced by another event prior to its occurrence.
Mutually exclusive: we call an event that its possiblities are mutually exclusive when the occurrence of one single outcome, say A, prevents the occurrence of the rest of all possible outcomes.
Example
Game 1
Objective: Suppose we have the experiment of taking a single ball out of a box which include 3 blue balls, 7 green balls, and 2 yellow balls. Each ball has a name starting with X and plus its number. For example, green X1, X2,X3…X7. blue X1, X2, X3, and yellow X1 and X2.
Possible outcomes:
- { Blue: X1, X2, X3,
Green: X1, X2, X3...X6, X7,
Yellow: X1, X2}
- *Mutually exclusive:* Taking out green X2, and yellow X2. Since we can only draw one once, when color green is drawn, color blue can not possibly be drawn. And vice versa. Therefore, these two colors are mutually exclusive.
- *Non-Mutually exclusive:* Taking out green X7 and Green X2. This is becasue when a green ball is taken out, it is impossible for other colors to be drawn, therefore, all other possibilities of other colored balls are eliminated. However, each of the 7 green balls have a 1/7 of probability of be drawn in this case. So they aren't mutually exclusiveGame 2
Objective: Suppose we can toss a 6 sided dice and then we can draw a ball from the same box that we have from the last game.
Possible outcomes:
{ dice: 1,2,3,4,5,6, each one of the numbers are possible.
balls: same as above from the previous game }
Independent: the event of obtaining a number from throwing the dice does not influence the outcome of drawing a ball from the box because these are two separate events. Therefore, we call these two events independent events.
Not independent: A non-independent situation can arise when we change the rules of this game. When we say ” we could draw from blue colored balls and yellow colored balls, when we get number from 1-3 from throwing the dice, and only the green balls, when 4-2 are tossed on the dice”. Now because the outcome of the dice directly influences the outcome of our ball-drawing game, therefore, we say that these two events are not independent.
titanic <- read.csv("/Users/pin.lyu/Desktop/BC_Class_Folder/Data_Analysis/DS_ASSIGNMENT/titanic/train.csv")
# Check for N/A values
colSums(is.na(titanic))
## PassengerId Survived Pclass Name Sex Age
## 0 0 0 0 0 177
## SibSp Parch Ticket Fare Cabin Embarked
## 0 0 0 0 0 0
# Create a table, including Survived, Sex, and Pclass
table(titanic$Survived,
titanic$Sex,
titanic$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