Dice rolls. (3.6, p. 92) If you roll a pair of fair dice, what is the probability of
diceSides <- 6
twoDice <- matrix(nrow = diceSides, ncol = diceSides)
for (die1 in 1:diceSides) {
for (die2 in 1:diceSides) {
twoDice[die1, die2] = die1 + die2
}
}
outcomes <- diceSides * diceSides
glue("(a) P(die1 + die2 == 1) is {round(sum(twoDice == 1) / outcomes, 3)}")
## (a) P(die1 + die2 == 1) is 0
glue("(b) P(die1 + die2 == 5) is {round(sum(twoDice == 5) / outcomes, 3)}")
## (b) P(die1 + die2 == 5) is 0.111
glue("(c) P(die1 + die2 == 12) is {round(sum(twoDice == 12) / outcomes, 3)}")
## (c) P(die1 + die2 == 12) is 0.028
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.
print("(a) They aren't disjoint, because some people fall into both groups.")
## [1] "(a) They aren't disjoint, because some people fall into both groups."
poverty <- .146
language <- .207
overlap <- .042
grid.newpage()
v <-draw.pairwise.venn(area1 = poverty,
area2 = language,
cross.area = overlap,
fill = c('green', 'blue'),
category = c('poverty', 'foreign \nlanguage'),
)
glue("(c) {100 * (poverty - overlap)}%")
## (c) 10.4%
glue("(d) {100 * (language + poverty - overlap)}%")
## (d) 31.1%
glue("(e) {100 * (1 - poverty - language + overlap)}%")
## (e) 68.9%
glue("(f) The probability of speaking a foreign language at home is {language}.
If you live below the poverty line, the probability that you speak a
foreign language at home is {round(overlap / poverty, 3)}. So the two events are
not independent.")
## (f) The probability of speaking a foreign language at home is 0.207.
## If you live below the poverty line, the probability that you speak a
## foreign language at home is 0.288. So the two events are
## not independent.
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.
(108 + 114 - 78) / 204
## [1] 0.7058824
78 / 114
## [1] 0.6842105
19 / 54
## [1] 0.3518519
11 / 36
## [1] 0.3055556
glue("The proportion of female partners that has blue eyes is
{round(108 / 204, 3)}, but if you know the color of the male partner's
eyes, the female blue proportions go as high as .684 (male blue)
or as low as .305 (male green). So no, they don't appear independent.")
## The proportion of female partners that has blue eyes is
## 0.529, but if you know the color of the male partner's
## eyes, the female blue proportions go as high as .684 (male blue)
## or as low as .305 (male green). So no, they don't appear independent.
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.
(28 / 95) * (59 / 94)
## [1] 0.1849944
fiction <- (72 / 95)
hard_if_hard_drawn_first <- (13 / 72) * (27 / 94)
hard_if_paper_drawn_first <- (59 / 72) * (28 / 94)
fiction * (hard_if_hard_drawn_first + hard_if_paper_drawn_first)
## [1] 0.2243001
(72 / 95) * (28 / 95)
## [1] 0.2233795
glue("The first condition is the same in both cases. You drew a fiction book
off the shelf. The probability of that fiction book being a paperback is
{round(59 / 72, 3)}. The overall proportion of paperbacks is
{round(67 / 95, 3)}, which is close enough that for the most part
you don't affect your chances much of drawing a hardcover on your second
draw, if you put the book back (although since the odds are slightly
higher that it's a paperback once you know it's fiction, you're better
off not replacing it, if you want to draw a hardcover next). Also
important is the fact that 28 out of 95 books are hardcovers, so even
if most fiction books were hardcovers instead of paperbacks, the
probability of drawing a hardcover after a fiction book would change by
less than 1/28 due to your choice of replacing or not after the first draw.")
## The first condition is the same in both cases. You drew a fiction book
## off the shelf. The probability of that fiction book being a paperback is
## 0.819. The overall proportion of paperbacks is
## 0.705, which is close enough that for the most part
## you don't affect your chances much of drawing a hardcover on your second
## draw, if you put the book back (although since the odds are slightly
## higher that it's a paperback once you know it's fiction, you're better
## off not replacing it, if you want to draw a hardcover next). Also
## important is the fact that 28 out of 95 books are hardcovers, so even
## if most fiction books were hardcovers instead of paperbacks, the
## probability of drawing a hardcover after a fiction book would change by
## less than 1/28 due to your choice of replacing or not after the first draw.
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.
avg <- .34 * 25 + .12 * 60
vary <- .54 * avg^2 + .34 * (25 - avg)^2 + .12 * (60 - avg)^2
std <- sqrt(vary)
glue("(a) Avg.rev/passenger is ${format(round(avg, 2), nsmall = 2)},
with a std.deviation of ${(format(round(std, 2), nsmall = 2))}")
## (a) Avg.rev/passenger is $15.70,
## with a std.deviation of $19.95
glue("About ${format(round(120 * avg, 2), nsmall = 2)} would be the expected
revenue, with about ${format(round(sqrt(120 * vary), 2), nsmall = 2)}
std.deviation.")
## About $1884.00 would be the expected
## revenue, with about $218.54
## std.deviation.
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.
It looks somewhat normally distibuted, with a median a little over $40K, perhaps, near the peak, and with the mean a bit higher due to a long tail to the right (so I guess a right skew).
glue("{.622 * .41}, assuming gender is independent from income.")
## 0.25502, assuming gender is independent from income.
Note any assumptions you make.