Independence:If event A&B are exclusive by comparing the observed frequencies (those noticed in the sample) , is hampered when there is clear evidence of personal bias Mutually exclusive:A coin toss is an example of a mutually exclusive event. Two events are mutually exclusive if they cannot happen simultaneously. The result of tossing a coin can be either heads or tails, but neither outcome can happen at the same time.
0=T 1=H
s<- data.frame(land = c("down", "up"))
s
## land
## 1 down
## 2 up
The sample space s is the column lands. The outcomes are down, up and side. so there are 2 posibilities, flip coin 10 times
sample(0:1,10,rep=T)
## [1] 0 1 1 1 0 0 0 0 1 0
We got 6H, and 4T, write a function to tossing coin n times
TossCoin=function(n) sample (0:1,n,rep=T)
e1=TossCoin(20)
e1
## [1] 0 1 0 1 0 0 1 1 0 1 1 1 1 1 0 1 0 0 0 0
Now use the sum command to test the probabilities.let’s tossing coin 20 times
sum(e1==0)
## [1] 10
sum(e1==0)/20
## [1] 0.5
sum(e1==1)
## [1] 10
sum(e1==1)/20
## [1] 0.5
We got 10T and 10H, the probability of a trail in this experiment is 0.5 and a Head is also 0.5
mydata <-read.csv("/Users/timyang/Documents/Train CSV/train.csv")
table(mydata$Survived,
mydata$Sex,
mydata$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
There are more female survived than male.