```
p.red<-54/(54+9+75)
p.blue<-75/(54+9+75)
p.red_or_blue <- p.red + p.blue
round(p.red_or_blue,4)
```

`## [1] 0.9348`

```
p.red<-20/(19+20+24+17)
round(p.red,4)
```

`## [1] 0.25`

```
males<-(81+116+215+130+129)
females<-(228+79+252+97+72)
living_with_parents<-215+252
not_living_with_parents<-(81+228+116+79+130+97+129+72)
females_not_living_with_parents<-(228+79+97+72)
p.female_or_not_living_with_parents<-(females+not_living_with_parents-females_not_living_with_parents)/1399
round(p.female_or_not_living_with_parents,4)
```

`## [1] 0.8463`

The 2 events should be dependent because the conditional probability of losing weight when going to the gym is expected to be different from the unconditional probability of losing weight. Since one event has an impact on the probability of the other, they are not independent.

`(no.of.wraps<-3*choose(8,3)*choose(7,3))`

`## [1] 5880`

These 2 events are independent because their conditional probability should be the same as their unconditional probability, because the occurence of one does not impact the occurrence of the other.

Since the rank matters, that means this is a permutation as opposed to a combination. n = 14 and r = 8.

`(factorial(14)/factorial(6))`

`## [1] 121080960`

The probability is equal to the number of ways in which 1 jellybean can be chosen from the 4 orange jellybeans, and 3 jellybeans can be chosen from the 9 green jellybeans, divided by the number of ways in which 4 jellybeans can be chosen from total of 22 jellybeans.

`round(((choose(9,0)*choose(4,1)*choose(9,3))/choose(22,4)),4)`

`## [1] 0.0459`

`(factorial(11)/factorial(7))`

`## [1] 7920`

The complement is: 33% of subscribers to a fitness magazine are 34 years or below.

Since the order does not matter, this is a combination problem. The number of ways in which you can get exactly 3 heads in 4 coin tosses is 4!/3! i.e. 4 The total number of combinations is 2 ^ 4 = 16

`(exp.value<-(4/16*97-12/16*30))`

`## [1] 1.75`

`559*1.75`

`## [1] 978.25`

I would expect to win $978.25

The total number of results is 2^9 Number of ways in which you can get r tails in n coin flips is n!/(r!(n-r)!)

```
total_set<-2^9
tails4<-choose(9,4)
tails3<-choose(9,3)
tails2<-choose(9,2)
tails1<-choose(9,1)
tails0<-choose(9,0)
tails.4.or.less<-sum(tails4,tails3,tails2,tails1,tails0)
prob.tails.4.or.less<-tails.4.or.less/total_set
tails.5.or.above<-total_set-tails.4.or.less
prob.tails.5.or.above<-tails.5.or.above/total_set
(exp.value<- -prob.tails.4.or.less*23+prob.tails.5.or.above*26)
```

`## [1] 1.5`

The expected value to me is $1.5

`(994*1.5)`

`## [1] 1491`

I’d expect to win $1,491, if I played this game 994 times

\(P(Liar|PolygraphLiar)=P(Liar \cap PolygraphLiar)/P(PolygraphLiar\)

p(Liar)=0.2 Therefore p(TruthTeller)=1-0.2=0.8

p(PolygraphLiar|Liar)=0.59 Therefore p(PolygraphLiar and Liar)=0.2*0.59=0.118 Therefore p(PolygraphTruthTeller and Liar)=0.2*0.41=0.082

p(PolygraphTruthTeller|TruthTeller)=0.90 Therefore p(PolygraphTruthTeller and TruthTeller)=0.9*0.8=0.72 Therefore p(PolygraphLiar and TruthTeller)=0.1*0.8=0.08

```
p.liar<-0.2
p.poly.liar.and.liar<-0.118
p.poly.liar.and.truthteller<-0.08
(p.liar.given.poly.liar<-p.poly.liar.and.liar/(p.poly.liar.and.liar+p.poly.liar.and.truthteller))
```

`## [1] 0.5959596`

```
p.truthteller<-0.8
p.poly.truthteller.and.truthteller<-0.72
p.poly.truthteller.and.liar<-0.082
(p.truthteller.given.poly.truthteller<-p.poly.truthteller.and.truthteller/(p.poly.truthteller.and.truthteller+p.poly.truthteller.and.liar))
```

`## [1] 0.8977556`

This is equal to probability that the individual is a liar + probability that the polygraph detected the individual to be a liar - probability that the individual is a liar and the polygraph detected the individual to be a liar

```
p.poly.liar<-(p.poly.liar.and.liar+p.poly.liar.and.truthteller)
(p.liar.or.poly.liar=p.liar+p.poly.liar-p.poly.liar.and.liar)
```

`## [1] 0.28`