library(grid)
library(futile.logger)
library(VennDiagram)
## Warning: package 'VennDiagram' was built under R version 3.4.4
library(knitr)
(2.6) Dice rolls. If you roll a pair of fair dice, what is the probability of
(a) getting a sum of 1?
Zero. Because fair dice has a minimum value of 1. Hence sum cannot be equal to 1.
(b) getting a sum of 5?
Sum of 5 can happen multiple ways. 1+4, 2+3, 3+2, 4+1. Hence probability of getting 5 is 4/36.
(c) getting a sum of 12?
Sum of 12 can happen only one way. 6+6. Hence probability of getting 12 is 1/36
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.59
(a) Are living below the poverty line and speaking a foreign language at home disjoint?
These events are not disjoint. It is possible for the subject to speak both a foreign language and live below the poverty line.
(b) Draw a Venn diagram summarizing the variables and their associated probabilities.
BPL = 14.6
SFL = 20.7
JOINT = 4.2
grid.newpage()
VD = draw.pairwise.venn(BPL,SFL,cross.area=JOINT,category = c("BPL","SFL"), fill = c('red','purple'))
(c) What percent of Americans live below the poverty line and only speak English at home?
The venn diagram shows us that this % is 10.4
(d) What percent of Americans live below the poverty line or speak a foreign language at home?
The venn diagram shows us that this % is 26.9
(e) What percent of Americans live above the poverty line and only speak English at home?
#Subtract Belowpoverty from 100% and subtract Foregin language from the remainder.
APL = 100-BPL
APLE = APL - SFL
APLE
## [1] 64.7
(f) Is the event that someone lives below the poverty line independent of the event that the person speaks a foreign language at home?
Since the ven diagram crosses i think they are probably dependent to some extent.
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.
(a) Find the probability of drawing a hardcover book first then a paperback fiction book second when drawing without replacement.
Probability of drawing a hardcover = Total hardcover books / Total books = 28/95 = 0.2947.
Since second book is drawn without replacement probability of drawing a fiction = ((72 - 1) / (95 - 1)) = 0.7553.
Probability of drawing a hardcover book first then a paperback fiction book second when drawing without replacement is (28/95 * ((72 - 1) / (95 - 1))) = 0.2226
(b) Determine the probability of drawing a fiction book first and then a hardcover book second, when drawing without replacement.
Probability of drawing a fiction = Total fiction books / Total books = 72/95 = 0.7578.
Since second book is drawn without replacement probability of drawing a hardcover = ((28 - 1) / (95 - 1)) = 0.2872.
Probability of drawing a hardcover book first then a paperback fiction book second when drawing without replacement is (72/95 * ((28 - 1) / (95 - 1))) = 0.21769
(c) Calculate the probability of the scenario in part (b), except this time complete the calculations under the scenario where the first book is placed back on the bookcase before randomly drawing the second book.
Probability of drawing a fiction = Total fiction books / Total books = 72/95 = 0.7578.
Since second book is drawn with replacement probability of drawing a hardcover = 28/95 = 0.2947.
Probability of drawing a hardcover book first then a paperback fiction book second when drawing with replacement is (72/95 * (28/95)) = 0.2233
(d) The final answers to parts (b) and (c) are very similar. Explain why this is the case.
In this case the difference is 1/95th because one out of 95 books is replaced/not-replaced.
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.
(a) Build a probability model, compute the average revenue per passenger, and compute the corresponding standard deviation.
NumBags = c(0,1,2)
BagCharge = c(0,25,35)
ProbBag = c(.54,.34,.12)
df = data.frame(NumBags,BagCharge,ProbBag)
df$ReV = df$BagCharge*df$ProbBag
Rpp = sum(df$ReV)
Sdpp = sd(df$ReV)
Rpp #Average revenue per passenger
## [1] 12.7
Sdpp #Standard deviation of revenue per passenger
## [1] 4.250098
(b) About how much revenue should the airline expect for a flight of 120 passengers? With what standard deviation? Note any assumptions you make and if you think they are justified.
Rpp*120 #Revenue per passanger multiplied by Number of Passengers
## [1] 1524
Sdpp*120 #SD per passanger multiplied by Number of Passengers
## [1] 510.0118
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.
(a) Describe the distribution of total personal income.
Distribution of total personal income looks like bell curve, with peak around $35,000 to $49,999 income range.
(b) What is the probability that a randomly chosen US resident makes less than $50,000 per year?
Adding the percentages of people making less than 50k Percentage of people making less than $50,000 is 2.2 + 4.7 + 15.8 + 18.3 + 21.2 = 62.2%. So probability is 0.622.
(c) What is the probability that a randomly chosen US resident makes less than $50,000 per year and is female? Note any assumptions you make.
Probability of male or female is 0.5. From above step it is established probability of picking a person making less than $50,000 is 0.622. Probability of picking female making less $50,000 is 0.622*0.5 = 0.311.
(d) The same data source indicates that 71.8% of females make less than $50,000 per year. Use this value to determine whether or not the assumption you made in part (c) is valid.
If 71.8% females are making less than $50,000, That would mean gender distribution is uneven. Assuming person is picked at random previous assumption still holds.
Apendix
library(grid)
library(futile.logger)
library(VennDiagram)
library(knitr)
BPL = 14.6
SFL = 20.7
JOINT = 4.2
grid.newpage()
VD = draw.pairwise.venn(BPL,SFL,cross.area=JOINT,category = c("BPL","SFL"), fill = c('red','purple'))
#Subtract Belowpoverty from 100% and subtract Foregin language from the remainder.
APL = 100-BPL
APLE = APL - SFL
APLE
NumBags = c(0,1,2)
BagCharge = c(0,25,35)
ProbBag = c(.54,.34,.12)
df = data.frame(NumBags,BagCharge,ProbBag)
df$ReV = df$BagCharge*df$ProbBag
Rpp = sum(df$ReV)
Sdpp = sd(df$ReV)
Rpp #Average revenue per passenger
Sdpp #Standard deviation of revenue per passenger
Rpp*120 #Revenue per passanger multiplied by Number of Passengers
Sdpp*120 #SD per passanger multiplied by Number of Passengers
``