p1<-(54/(54+9+75))+(75/(54+9+75))
round(p1, 4)
## [1] 0.9348
\[ \frac{20}{19+20+24+17} \]
p2<-20/(19+20+24+17)
round(p2, 4)
## [1] 0.25
Lets make this table into a data frame so we can work with the given data https://www.rdocumentation.org/packages/knitr/versions/1.20/topics/kable
library(knitr)
#Define attributes
Housing <- c("Apartment","Dorm","With Parent(s)","Sorority/Fraternity House","Other")
Males <- c(81,116,215,130,129)
Females <- c(228,79,252,97,72)
df <- data.frame(Housing,Males,Females)
colnames(df) <- c("Housing Type","Males","Females")
#use kable to assemble into similar looking table as in the problem statement
kable(df, format = "pandoc",full_width = F,caption = "Gender and Residence of Customers", position = "left")
| Housing Type | Males | Females |
|---|---|---|
| Apartment | 81 | 228 |
| Dorm | 116 | 79 |
| With Parent(s) | 215 | 252 |
| Sorority/Fraternity House | 130 | 97 |
| Other | 129 | 72 |
What is the probability that a customer is not male or does not live with parents? Write your answer as a fraction or a decimal number rounded to four decimal places.
We sum down the column in the table and divide by total number of participants.
\[ \frac{228+79+252+97+72}{1399}+\frac{212+252}{1399} \]
sum=81+116+215+130+129+228+79+252+97+72
notmale_prob=(228+79+252+97+72)/sum
notparents_prob=(212+252)/sum
round(notmale_prob+notparents_prob, 4)
## [1] 0.852
The following events are dependent. Fitness is correlated with a healthy weight. Fitness depends on weight
choose(8,3) * choose(7,3) * choose(3,1)
## [1] 5880
7)The newly elected president needs to decide the remaining 8 spots available in the cabinet he/she is appointing. If there are 14 eligible candidates for these positions (where rank matters), how many different ways can the members of the cabinet be appointed?
This is a case of permutation since order matters There is no function for permutations so lets make a simple one
permutations <- function(n,k)
{
choose(n,k) * factorial(k)
}
permutations(14, 8)
## [1] 121080960
p8_n<-choose(9,0)*choose(4,1)*choose(9,3)
p8_k<-choose((9+4+9),4)
p8<-p8_n/p8_k
round(p8, 4)
## [1] 0.0459
11*10*9*8
## [1] 7920
\[ \frac{11!}{7!}=\frac{11\cdot10\cdot9\cdot8\cdot7!}{7!}=11\cdot10\cdot9\cdot8=7920 \]
Describe the complement of the given event. 67% of subscribers to a fitness magazine are over the age of 3 33% of subscribers are 34 and younger
If you throw exactly three heads in four tosses of a coin you win $97. If not, you pay me $30. Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
w <- pbinom(3, size=4, prob=0.5) - pbinom(2, size=4, prob=0.5)
l <- 1 - w
w1<-w*97
l1<-l*30
4*0.5^4*(97) + (1+4+6+1)* 0.5^4 * (-30)
## [1] 1.75
Step 2. If you played this game 559 times how much would you expect to win or lose? (Losses must be entered as negative.)
round(559*(w1-l1), 2)
## [1] 978.25
(9*2*7+3*4*7+9*4+9+1)*0.5^9*(23-26)
## [1] -1.5
Step 2. If you played this game 994 times how much would you expect to win or lose? (Losses must be entered as negative.)
994 * (-1.5)
## [1] -1491
Lets collect our givens within variables
prob_Liar <- 0.2
prob_Truth <- 0.8
senstivity <- 0.59
specificity <- 0.90
prob_detect_liar <- 0.59 * prob_Liar
prob_detect_truth <- 0.90 * prob_Truth
prob_false_detect_liar <- (1-0.59)*prob_Liar
prob_false_detect_truth <- (1-0.9)*prob_Truth
prob_detect_liar /(prob_detect_liar + prob_false_detect_truth)
## [1] 0.5959596
prob_detect_truth / (prob_detect_truth + prob_false_detect_liar)
## [1] 0.8977556
We should consider use of inclusion exclusion formula
\[ P(liar\bigcup { detect\_ liar)=P(liar)+P(detect\_ liar)-P(liar\bigcap { detect\_ liar)}} \\ =0.2+0.59-0.118\\ =0.672 \]