```python
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import expon
from typing import List
```

(a) Let the random variable $x$ be the lifetime of a light bulb in days. We assume that the lifetime is exponential with density:
$$p(x) = \lambda^{-1} e^{-x/\lambda}$$

Then given $\lambda$ (the mean time to failure):
$$ P (x \ge 30) = 1 - cdf(p(x)) = e^{-x/\lambda}$$

(b) Let $x_1,...,x_n \sim Exp(\lambda)$. The contribution of $x_i$ to the likelihood is:
$$L_i(\lambda) = \lambda^{-1} e^{-x/\lambda}$$

and the total log-likelihood is:
\begin{align}
\log L(\lambda) & = \sum_{i=1}^n \log L_i(\lambda) \\
& = -n \log \lambda - \frac{1}{\lambda} \sum_{i=1}^n x_i \\
& = -n (\log \lambda + \bar{x}/\lambda)
\end{align}


```python
data = np.array([6, 28]) # only the first two order statistics are reported
n = data.shape[0]
x_bar = np.mean(data)
lambda_ = np.linspace(1, 30, 100)
```


```python
log_like = -n * (np.log(lambda_) + x_bar / lambda_)
likelihood = np.exp(log_like)
likelihood /= np.max(likelihood)
```


```python
plt.plot(lambda_, likelihood)
plt.title('Light bulb failure likelihood')
plt.xlabel(r'$\lambda$')
plt.ylabel('Likelihood');
```

Not at all sure about parts (d) and (e). 

11d28a0749cd9fd572bccf9090f2aa319e3542d4
ipynb
Jupyter Notebook
python/chapter-2/exercises/EX2-11.ipynb
covuworie/in-all-likelihood
6638bec8bb4dde7271adb5941d1c66e7fbe12526
MIT
python/chapter-2/exercises/EX2-11.ipynb
covuworie/in-all-likelihood
6638bec8bb4dde7271adb5941d1c66e7fbe12526
MIT
2020-03-24T17:53:04.000Z
2021-08-23T20:16:17.000Z
python/chapter-2/exercises/EX2-11.ipynb
covuworie/in-all-likelihood
6638bec8bb4dde7271adb5941d1c66e7fbe12526
MIT
2021-11-21T10:24:59.000Z
2021-11-21T10:24:59.000Z
Qwen/Qwen-72B
1. YES
2. YES