Caution
Section omitted to comply with the Honor Code
Bayesian Statistics: From Concept to Data Analysis
Oren Bochman
Distributions, Homework
Section omitted to comply with the Honor Code
---
title: "Homework on Distributions - M1L3HW2"
subtitle: "Bayesian Statistics: From Concept to Data Analysis"
categories:
- Bayesian Statistics
keywords:
- Distributions
- Homework
---
::::: {.content-visible unless-profile="HC"}
::: {.callout-caution}
Section omitted to comply with the Honor Code
:::
:::::
::::: {.content-hidden unless-profile="HC"}
:::: {#exr-distributions-1}
If RV $X$ has a probability density function (PDF) $f(x)$, what is the interpretation of $\int_{−2}^5 f(x)dx$ ?
::::
::: {.solution .callout-tip collapse="true"}
#### Solution:
Since the area under the PDF curve is the probability, integrating the PDF calculates the total probability within the range of the integral. We can write this probability in several forms.
$$
\mathbb{P}r(X \ge -2 \cap X \le 5)
$$
or a more sensible notation
$$
\mathbb{P}r(-s \ge X \ge 5)
$$
:::
:::: {#exr-distributions-2}
If $X \sim \text{Uniform}(0,1)$, then what is the value of $\mathbb{P}r(−3 < X < 0.2)$?
::::
::: {.solution .callout-tip collapse="true"}
#### Solution:
$$
\int_{−3}^{0.2} I_{[0,1]} dx = \int_{0}^{0.2} 1 dx = 0.2
$$
:::
:::: {#exr-distributions-3}
If $X \sim \text{Exponetial}(5)$, then what is $\mathbb{E}(X)$ ?
::::
::: {.solution .callout-tip collapse="true"}
#### Solution:
$$
\mathbb{E}(X) = \frac{1}{\lambda} = \frac{1}{5} = 0.2
$$
:::
:::: {#exr-distributions-4}
Which of the following scenarios could we most appropriately model using an exponentially distributed random variable?
::::
::: {.solution .callout-tip collapse="true"}
#### Solution:
The exponential distribution models the times between events so I would go with the lifetime of a light-bulb.
:::
:::: {#exr-distributions-5}
if $X \sim \text{Uniform}(2,6)$ what would its PDF look like?
::::
::: {.solution .callout-tip collapse="true"}
#### Solution:
```{python}
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from scipy.stats import uniform
x= np.arange(0.0,8.0,0.001)
fig, ax = plt.subplots()
plt.plot(x, uniform.pdf(x,loc=2,scale=4))
#values = uniform(2.0, 6.00, 1000)
#sns.histplot(values,kde=True,bins=10,ax=ax)
ax.set_xlim(0,10)
ax.set_ylim(0,0.4)
plt.show()
```
This PDF has a uniform value (1/4) over the interval \[2,6\] and is 0 everywhere else.
:::
:::: {#exr-distributions-6}
If $X \sim \text{Uniform}(2,6)$, then what is the value of $\mathbb{P}r(2 < X < 3.2)$ ?
::::
::: {.solution .callout-tip collapse="true"}
#### Solution:
$$
\int_{3}^{2} 1/4 dx = 0.25
$$
:::
:::: {#exr-distributions-7}
if $X∼N(0,1)$, which is the PDF of X
::::
::: {.solution .callout-tip collapse="true"}
#### Solution:
```{python}
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import uniform, norm
x= np.arange(-3.,3.0,0.001)
fig, ax = plt.subplots()
plt.plot(x, norm.pdf(x,loc=0,scale=1))
#values = uniform(2.0, 6.00, 1000)
#sns.histplot(values,kde=True,bins=10,ax=ax)
ax.set_xlim(-3,3)
ax.set_ylim(0,.5)
plt.show()
```
:::
:::: {#exr-distributions-8}
if $X∼N(2,1)$, which is $\mathbb{E}(-5X)$
::::
::: {.solution .callout-tip collapse="true"}
#### Solution:
$$
\mathbb{E}(-5X)=-5\mathbb{E}(X)=-5 \times2=-10
$$
:::
:::: {#exr-distributions-9}
if $X∼N(1,1)$, and $Y\sim N(4,9)$ which is $\mathbb{E}(X+Y)$
::::
::: {.solution .callout-tip collapse="true"}
#### Solution:
$$
\mathbb{E}(X+Y) = \mathbb{E}(X)+\mathbb{E}(Y)= 1 + 4 = 5
$$
:::
:::: {#exr-distributions-10}
The normal distribution is also linear in the sense that if $X\sim N(\mu,\sigma^2)$, then for any real constants $a\ne 0$ and $b Y=aX+b$ is distributed $N(a\times \mu +b,a^2\times \sigma^2)$.
Using this fact, what is the distribution of $Z = \frac{X-\mu}{\sigma}$ ?
::::
::: {.solution .callout-tip collapse="true"}
#### Solution:
$Z=N(0,1)$
:::
:::: {#exr-distributions-11}
11. Which of the following random variables would yield the highest value of $\mathbb{P}r(−1<X<1)$ ?
::: {.callout-note collapse="true"}
#### Hint:
Random variables with larger variance are more dispersed.
:::
::::
::: {.solution .callout-tip collapse="true"}
#### Solution:
- [ ] $X_1 \sim N(0,0.1)$
- [ ] $X_2 \sim N(0,1)$
- [ ] $X_3 \sim N(0,10)$
- [x] $X_4 \sim N(0,100)$
Of the four options, $X_4$ is the least dispersed, meaning that most of the probability is associated with small values of X.
:::
:::::