2.6 Dice rolls. If you roll a pair of fair dice, what is the probability of (a) getting a sum of 1? Answer: Since, there are two dice and minimum you can get on each dice is 1 whose total is 2 this question is not valid.
total_chances <- 4
total_possible_outcomes <- 36
probability <- total_chances / total_possible_outcomes
probability
## [1] 0.1111111
total_chances <- 1
total_possible_outcomes <- 36
probability <- total_chances / total_possible_outcomes
probability
## [1] 0.02777778
2.8 Poverty and language. The American Community Survey is an ongoing survey that provides data every year to give communities the current information they need to plan investments and services. The 2010 American Community Survey estimates that 14.6% of Americans live below the poverty line, 20.7% speak a language other than English (foreign language) at home, and 4.2% fall into both categories.
Are living below the poverty line and speaking a foreign language at home disjoint? Answer: No, because given statement above mentions that 4.2% fall into both categories: below poverty line and speak other language than English at home.
Draw a Venn diagram summarizing the variables and their associated probabilities. Answer:
library(VennDiagram)
## Warning: package 'VennDiagram' was built under R version 3.5.1
## Loading required package: grid
## Loading required package: futile.logger
## Warning: package 'futile.logger' was built under R version 3.5.1
grid.newpage()
draw.pairwise.venn(14.6, 20.7, 4.2, category = c("Dog People", "Cat People"), lty = rep("blank",
2), fill = c("light blue", "pink"), scaled = FALSE)
## (polygon[GRID.polygon.1], polygon[GRID.polygon.2], polygon[GRID.polygon.3], polygon[GRID.polygon.4], text[GRID.text.5], text[GRID.text.6], text[GRID.text.7], text[GRID.text.8], text[GRID.text.9])
PL <- 14.6
PLOtherLanguage <- 4.2
Below_PLEnlgish <- PL - PLOtherLanguage
Below_PLEnlgish
## [1] 10.4
PL <- 14.6
PLOtherthanEnglish <- 20.7
PLOtherLanguage <- 4.2
Below_PLEnlgish <- PL + PLOtherthanEnglish - PLOtherLanguage
Below_PLEnlgish
## [1] 31.1
PL <- 14.6
PLOtherthanEnglish <- 20.7
PLAbove <- 100 - PL
PLAboveOtherthanEnglish <- 100 - PLOtherthanEnglish
AmericanABovePLEnglish <- (PLAbove * PLAboveOtherthanEnglish)/100
AmericanABovePLEnglish
## [1] 67.7222
2.20 Assortative mating. Assortative mating is a nonrandom mating pattern where individuals with similar genotypes and/or phenotypes mate with one another more frequently than what would be expected under a random mating pattern. Researchers studying this topic collected data on eye colors of 204 Scandinavian men and their female partners. The table below summarizes the results. For simplicity, we only include heterosexual relationships in this exercise. Partner (female) Blue Brown Green Total Blue 78 23 13 114 Self (male) Brown 19 23 12 54 Green 11 9 16 36 Total 108 55 41 204
MBlue <- 114/204
FBlue <- 108/204
MFBlue <- 78/204
OnlyMBlue <- (MBlue + FBlue - MFBlue)*100
OnlyMBlue
## [1] 70.58824
MFBlue <- 78/204
MFprobability <- MFBlue*100
MFprobability
## [1] 38.23529
(19/204)*100
## [1] 9.313725
Probabilty of randomly chosen male respondent with green eyes has a partner with blue eyes is
(11/204)*100
## [1] 5.392157
2.30 Books on a bookshelf. The table below shows the distribution of books on a bookcase based on whether they are nonfiction or fiction and hardcover or paperback. Format Hardcover Paperback Total Type Fiction 13 59 72 Nonfiction 15 8 23 Total 28 67 95
PHF <- 28/95
PPF <- 59/94
ProbabilityHPFiction <- (PHF * PPF)*100
ProbabilityHPFiction
## [1] 18.49944
PFBook <- 72/95
PHBook <- 28/94
ProbabilityFBookHardBook <- (PFBook * PHBook)*100
ProbabilityFBookHardBook
## [1] 22.57559
PFBook <- 72/95
PHBook <- 28/95
ProbabilityFBookHardBook <- (PFBook * PHBook)*100
ProbabilityFBookHardBook
## [1] 22.33795
2.38 Baggage fees. An airline charges the following baggage fees: $25 for the first bag and $35 for the second. Suppose 54% of passengers have no checked luggage, 34% have one piece of checked luggage and 12% have two pieces. We suppose a negligible portion of people check more than two bags.
num_of_bags <- c('no bags', 'one bags', 'two bags')
baggage_fee <- c(0,25,35)
passengers <- c(0.54, 0.34, 0.12)
df <- data.frame(num_of_bags, passengers, baggage_fee)
avg_revenue <- (sum((df$passengers * df$baggage_fee))/sum(df$passengers))
avg_revenue
## [1] 12.7
Standard Deviation
sqrt(0.54*(0-avg_revenue)^2 + 0.34*(25-avg_revenue)^2 + 0.12*(35-avg_revenue)^2)
## [1] 14.07871
no_bags <- (54/100)*120
one_bag <- (34/100)*120
two_bag <- (12/100)*120
avg_revenue_120 <- (round(no_bags*0) + one_bag*25 + (two_bag*25 + two_bag*35))
avg_revenue_120
## [1] 1884
2.44 Income and gender. The relative frequency table below displays the distribution of annual total personal income (in 2009 inflation-adjusted dollars) for a representative sample of 96,420,486 Americans. These data come from the American Community Survey for 2005-2009. This sample is comprised of 59% males and 41% females.
income_range <- c("1 to $9999 or loss", "10,000 to 14,999", "15, 000 to 24,999", "25,000 to 34,999", "35,000 to 49,999", "50,000 to 64,999", "65,000 to 74,999", "75,000 to 99,999", "100,000 or more")
total <- c(.022, .047, 0.158, 0.183, 0.212, 0.139, 0.058, 0.084, 0.097)
df <- data.frame (income_range, total)
df
## income_range total
## 1 1 to $9999 or loss 0.022
## 2 10,000 to 14,999 0.047
## 3 15, 000 to 24,999 0.158
## 4 25,000 to 34,999 0.183
## 5 35,000 to 49,999 0.212
## 6 50,000 to 64,999 0.139
## 7 65,000 to 74,999 0.058
## 8 75,000 to 99,999 0.084
## 9 100,000 or more 0.097
barplot(total)
random_citizen <- sum(total[0:5])*100
random_citizen
## [1] 62.2
random_citizen <- sum(total[0:5])*100
random_citizen_female <- random_citizen*0.41
random_citizen_female
## [1] 25.502