[1] 4 1 4 3 4 6 6 5 6 5
[1] 3.427
[1] 1.714529
A variable is a placeholder for a quantity
\(x = 3,\ \ y=5, \ \ z=x^2+y^2\)
A random variable is, well, random - its value is the outcome of a random process
\[\displaystyle D = \begin{cases}1 & 1/6\\2 & 1/6\\3&1/6\\4&1/6\\5&1/6\\6&1/6\end{cases}\ \ \ \text{or} \ \ \ \ \ \text{Pr}(D=d) = 1/6 \ \ \ \ \text{for} \ \ d=1, 2, ..., 6\]
\[\begin{align}\displaystyle C = \begin{cases}1 & \text{if heads}\\0 & \text{if tails}\end{cases}\ \ \ \text{or} \ \ \ \ \ &\text{Pr}(C=c) = 1/2 \ \ \ \ \text{for} \ \ c=0,1\\ &C\sim\text{Bernoulli}(1/2)\end{align}\]
The CDF of a random variable contains all of the information about the outcomes of that RV.
We can approximate distribution functions through Monte Carlo simulation, if one is not already pre-defined.
Suppose we want to know the probability of getting at least 3 heads when flipping a coin 4x.
[1] 1 3 2 3 2 1 2 2 2 3
[1] 0.322
size and prob are set based on the problem – 4 coin flips, fair coin\[X\ =\ \begin{cases}1 & \text{bunny dies}\\2, ..., 12 & \text{bunny survives}\end{cases}\] \[Y\ =\ \begin{cases}1\ \text{on any die} & \text{bunny dies}\\2, ..., 12 \ \text{on every die} & \text{bunny survives}\end{cases}\]
[1] 5 6 9 11 2 12
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 2 4 10 4 6 12 1
[2,] 3 3 7 4 5 6 5
[3,] 7 5 2 6 1 7 4
[4,] 8 9 3 4 9 7 3
[5,] 2 12 1 2 6 5 3
[6,] 2 4 2 7 3 7 4
[1] 1 0 1 0 1 0 0 0 1 1 1 1 0 0 1 0 1 2 0 2
[1] 0.08288
[1] 0.45386
So, while there’s an 8% chance that the single whisk takes out a bunny, there’s a 45% chance that 7 whisks working together take out a bunny.
One of the most useful summaries of a random variable is the expected value
mean(x)The standard deviation describes how far, on average, a value is from the expected value.
sd(x)The standard error is the variability of an estimate. We might calculate the standard error of
\(\sigma\) is the standard deviation of \(X\)
\(\sigma/\sqrt{n}\) is the standard error of \(\overline X\)
\[E\left[\sum_{i=1}^n X_i \right] = \sum_{i=1}^n E\left[X_i\right]\]
If the \(X_i\) have the same distribution, then \(\displaystyle\sum_{i=1}^n E\left[X_i\right] = n E\left[X_i\right]\)
\[\begin{array}{rlrl} E[x]&= 5.028 &SD[x]&= 0.968\\ E[\sum_{i=1}^{10} x_i]&= 5.000& SD[\sum_{i=1}^{10} x_i]&= NA\end{array}\]
Scaling \(X_i\) works as expected:
\[E\left[a X_i + b\right] = a E\left[X_i\right]+b\]
and when \(X_i\) is scaled,
\[SD[aX_i + b] = |a| SD[X_i]\]
Shifting \(X_i\) by \(b\) does not change the variance, but multiplying by \(a\) does.
\[\begin{array}{rlrl} E[x]&= 1.854 &SD[x]&= 1.307\\ E[5 x + 3]&= 12.269& SD[5 x + 3]&= 6.534\\ 5\cdot E[x] + 3&= 12.269& 5\cdot SD[x]&= 6.534\end{array}\]
If \(X\sim\text{Normal}(\mu,\sigma)\), then \(aX + b\sim\text{Normal}(a\mu+b, a\sigma)\)
If \(X_i\) are independent (not related), then
\[\text{Var}\left[X_1 + ... + X_n\right] = \text{Var}\left[X_1\right] + ... + \text{Var}\left[X_n\right]\]
and so
\[\text{SD}\left[X_1 + ... + X_n\right] = \sqrt{\text{SD}\left[X_1\right]^2 + ... + \text{SD}\left[X_n\right]^2}\]
If \(X_i\) are also identically distributed then
\[\text{Var}\left[X_1 + ... + X_n\right] = n \text{Var}\left[X\right] \ \ \ \text{and}\ \ \ \ \text{SD}\left[X_1 + ... + X_n\right] = \sqrt{n} \text{SD}\left[X\right]\]
Consider \(\displaystyle\frac{1}{n} \sum_{i=1}^n X_i\) (the sample mean)
\[\displaystyle E\left[\frac{1}{n} \sum_{i=1}^n X_i\right] = \frac{1}{n}E\left[\sum_{i=1}^n X_i\right] = \frac{n}{n} E\left[X\right] = E\left[X\right]\]
\[\displaystyle \text{SD}\left[\frac{1}{n} \sum_{i=1}^n X_i\right] = \frac{1}{n} SD\left[\sum_{i=1}^n X_i\right] = \frac{\sqrt{n}\cdot\text{SD}\left[X\right]}{n} = \frac{\text{SD}\left[X\right]}{\sqrt{n}}\]
So, as \(n\) increases, the variability of sample mean decreases!
We may model the population with a chosen theoretical probability distribution that uses the population parameters
