= c(4,1,3,4,3,2,7,3,4,6,5,5,3,2,4,5,4,7,5,2) y
Homework 2. Bayes AI
Exercise 1 (Two Gambles) In an experiment, subjects were given the choice between two gambles:
Experiment 1 | |||
---|---|---|---|
Gamble \({\cal G}_A\) | Gamble \({\cal G}_B\) | ||
Win | Chance | Win | Chance |
$2500 | 0.33 | $2400 | 1 |
$2400 | 0.66 | ||
$0 | 0.01 |
Suppose that a person is an expected utility maximizer. Set the utility scale so that u($0) = 0 and u($2500) = 1. person is an expected utility maximizer. Set the utility scale so that u($0) = 0 and u($2500) = 1. Whether a utility maximizing person would choose Option A or Option B depends on the person’s utility for $2400. For what values of u($2400) would a rational person choose Option A? For what values would a rational person choose Option B?
Experiment 2 | |||
---|---|---|---|
Gamble \({\cal G}_C\) | Gamble \({\cal G}_D\) | ||
Win | Chance | Win | Chance |
$2500 | 0.33 | $2400 | 0.34 |
$0 | 0.67 | $0 | 0.66 |
For what values of u($2400) would a person choose Option C? For what values would a person choose Option D? Explain why no expected utility maximizer would prefer B and C.
This problem is a version of the famous Allais paradox, named after the prominent critic of subjective expected utility theory who first presented it. Kahneman and Tversky found that 82% of subjects preferred B over A, and 83% preferred C over D. Explain why no expected utility maximizer would prefer both B in Gamble 1 and C in Gamble 2. (A utility maximizer might prefer B in Gamble 1. A different utility maximizer might prefer C in Gamble 2. But the same utility maximizer would not prefer both B in Gamble 1 and C in Gamble
Discuss these results. Why do you think many people prefer B in Gamble 1 and C in Gamble 2? Do you think this is reasonable even if it does not conform to expected utility theory?
Exercise 2 (Tarone Study) Tarone (1982) reports data from 71 studies on tumor incidence in rats
- In one of the studies, 2 out of 13 rats had tumors. Assume there are 20 possible tumor probabilities: \(0.025, 0.075,\ldots, 0.975\). Assume that the tumor probability is uniformly distributed. Find the posterior distribution for the tumor probability given the data for this study.
- Repeat Part a for a second study in which 1 in 18 rats had a tumor.
- Parts a and b assumed that each study had a different tumor probability, and that these tumor probabilities were uniformly distributed a priori. Now, assume the tumor probabilities are the same for the two studies, and that this probability has a uniform prior distribution. Find the posterior distribution for the common tumor probability given the combined results from the two studies.
- Compare the three distributions for Parts a, b, and c. Comment on your results.
Exercise 3 (Poisson MLE vs Baye) You are developing tools for monitoring number of advertisemnt clicks on a website. You have observed the following data:
which represents the number of clicks every minute over the last 10 minutes. You assume that the number of clicks per minute follows a Poisson distribution with parameter \(\lambda\).
- Plot likelihood function for \(\lambda\).
- Estimate \(\lambda\) using Maximum Likelihood Estimation (MLE). MLE is the value of \(\lambda\) that maximizes the likelihood function or log-likelihood function. Maximizing likelihood is equivalent to maximizing the log-likelihood function (log is a monotonically increasing function).
- Using
barplot
, plot the predicted vs observed probabilities of for number of clicks from 1 to 7. Is the model a good fit? - Assume that you know, that historically, the average number of clicks per minute is 4 and variance is also 4. Those numbers were valculated over a long period of time. You can use this information as a prior. Assume that the prior distribution is \(Gamma(\alpha,\beta)\). What would be appropriate values for \(\alpha\) and \(\beta\) that would represent this prior information?
- Find the posterior distribution for \(\lambda\) and calculate the Bayesian estimate for \(\lambda\) as the expectation over the posterior.
- After collecting data for a few days, you realized that about 20% of the observations are zero. How this information would change your prior distribution? This is an open-ended question.
Hint: For part c, you can use the following code to calculate the predicted probabilities for the number of clicks from 0 to 5.
= table(y)
tb = tb/length(y)
observed = dpois(1:7,lambda_mle) predicted
Exercise 4 (Exponential Distribution) Let \(x_1, x_2,\ldots, x_N\) be an independent sample from the exponential distribution with density \(p (x | \lambda) = \lambda\exp (-\lambda x)\), \(x \ge 0\), \(\lambda> 0\). Find the maximum likelihood estimate \(\lambda_{\text{ML}}\). Choose the conjugate prior distribution \(p (\lambda)\), and find the posterior distribution \(p (\lambda | x_1,\ldots, x_N)\) and calculate the Bayesian estimate for \(\lambda\) as the expectation over the posterior.