Source files: https://github.com/djlofland/DATA606_F2019/tree/master/Homework3
## Loading required package: grid
## Loading required package: futile.logger
##
## Attaching package: 'formattable'
## The following object is masked from 'package:xtable':
##
## digits
Dice rolls. (3.6, p. 92) If you roll a pair of fair dice, what is the probability of
0 - the smallest sum you can roll would be 2 (each dice shows a 1)
To get a sum of five, we need to roll a 4 and 1 or a 2 and 3:
\[P(1)\ and\ P(4)\ or\ \\P(2)\ and\ P(3)]\ or\ \\P(4)\ and\ P(1)\ or\ \\P(3)\ and\ P(2)\]
\[\frac{1}{6} \times \frac{1}{6} + \frac{1}{6} \times \frac{1}{6} + \frac{1}{6} \times \frac{1}{6} + \frac{1}{6} \times \frac{1}{6} = \frac{4}{36} = \frac{1}{9}\]
The only way to get a sum of 12 is if both dice roll a 6:
\[\frac{1}{6} + \frac{1}{6} = \frac{1}{36}\]
Poverty and language. (3.8, p. 93) 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.
\[P(Poverty) = 14.5\%\\P(Other) = 20.7\%\\P(Poverty\ \textrm{and}\ Other) = 4.2\%\]
No. Since there is overlap of 4.2%, they are by definition NOT disjoint
grid.newpage()
draw.pairwise.venn(14.6, 20.7, 4.2, category = c("Below Poverty", "Foreign Language"), lty = rep("blank",
2), fill = c("light blue", "pink"), alpha = rep(0.5, 2), cat.pos = c(0,
0), cat.dist = rep(0.025, 2))## (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])
\[ P(Poverty) - P(Poverty\ \textrm{and}\ Foreign) = 14.6 - 4.2 = 10.4\%\]
\[ P(Poverty) + P(Foreign) - P(Poverty\ \textrm{and}\ Foreign) = \\14.6 + 20.7 - 4.2 = 31.1\%\]
\[ P(English\ \textrm{and}\ No Poverty)\\= 100 - P(Povery) + P(Other) - P(Poverty\ \textrm{and}\ Other)\\ = 100-(20.7+14.6-4.2) = 68.9\]
| English | Other | total | |
|---|---|---|---|
| No Poverty | 68.9 | 16.5 | 85.4 |
| Poverty | 10.4 | 4.2 | 14.6 |
| total | 79.3 | 20.7 | 100 |
\[P(Poverty | Engish) = \frac{10.4}{69.9 + 10.4} = 0.1295143 \\P(Poverty | NonEnglish) = \frac{4.2}{16.5+4.2} = 0.2028986\]
Since there is a higher probability that you are in Poverty given NonEnglish (20.3%) versus Poverty given English (12.9%), the variables are likely dependent. If they were independent, we’d expect to see similar probabilities.
Assortative mating. (3.18, p. 111) 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.
fema_blue <- 108 / 204
male_blue <- 114 / 204
both_blue <- 78 / 204
either_blue <- fema_blue + male_blue - both_blue\[P(f\_blue\ or\ m\_blue) = 70.59% \% \]
\[P(BlueFemale | BlueMale) = \frac{P(BlueFemale\ and \ BlueMale)}{P(BlueMale)}\\ = \frac{\frac{78}{204}}{\frac{114}{204}}\\ =68.42%\ \% \]
\[P(BlueFemale | BrownMale) = \frac{P(BlueFemale\ and\ BrownMale)}{P(BrownMale)}\\ = \frac{\frac{19}{204}}{\frac{54}{204}}\\ =35.19%\ \% \] >
Portions of Female Eye color given male’s eye color
| Blue | Brown | Green | |
|---|---|---|---|
| Blue | 68.42% | 20.18% | 11.40% |
| Brown | 35.19% | 42.59% | 22.22% |
| Green | 30.56% | 25.00% | 44.44% |
Choices in eye color are clearly dependent … if eye color choice we independent, we’d expect to see similar proportions between the colors. We in fact see that people are more likely to choose a partner with the same eye color as themselves.
Books on a bookshelf. (3.26, p. 114) The table below shows the distribution of books on a bookcase based on whether they are nonfiction or fiction and hardcover or paperback.
\[P(Total) = P(H) * P(P)\]
total <- 95
p_H <- 28 / total
total <- total - 1 # Without replacment, we removed 1 book
p_P <- 28 / total
final <- p_H * p_PThe overall probability is 8.78%.
\[P(Total) = P(F) * P(H)\]
The overall probability is 22.58%.
\[P(Total) = P(F) * P(H)\]
The overall probability is 22.34%.
We have a large sample size of 95 books, so loosing 1 has ~1% impact on the overall total. The book portions mean that that only a fraction of this ~1% was realized between parts (b) and (c)
Baggage fees. (3.34, p. 124) 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.
## [1] 4.233333
## [1] 4.250098
## [1] 1524
Income and gender. (3.38, p. 128) 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.
inc <- c(5, 12.5, 20, 29.5, 42.5, 57.5, 70, 88, 110)
tot <- c(0.022, 0.047, 0.158, 0.183, 0.212, 0.139, 0.058, 0.084, 0.097)
plot(inc, tot)left skewed with probably a longtail to the right
## [1] 1
## [1] 0.622
The probability is 62.20%
\[P(Total) = P(Less\ than\ 50000) * P(Female) \]
## [1] 0.25502
I’m assuming that income and gender are independent (ha!) … a very poor assumption. My hypothesis is that income and gender are very dependent with more lower income females than males and as a result the probablility of drawning a low income female is probably higher than the 25.50% calculation.
71.8% is significantly higher than 25.5% which confirms that there is a strong correlation between gender and income. I was correct in assuming that 25.5% was low, but I wouldn’t have guess it was as high as 71%.