A random variable is a numerical outcome to a random process.
eg. A student has an assigned text book for a course. How much a random student in the course spends on the text book is a random variable, \(X\).
random variables are usually denoted with capitals \(X\),\(Y\),\(Z\)
The book store assumes that students will either: not buy a book, buy the book used, or buy it brand new. The possible outcomes are usually denoted with lower case letters.
Revenue for the book store is \(x_1 = 0\), \(x_2 = 137\), \(x_3 = 170\) for the three possbilities and the book store believes they each occur with probability \(.20\), \(.55\), and \(.25\) respectively. In probability notation:
\[P(X=0) = .20, \ P(X=137) = .55, \ P(X=170) = .25\]
Since there are only three possible outcomes, this is called a discrete probability distribution
probs <- c(.2,.55,.25)
book_prices <- c(0,137,170)
barplot(probs~book_prices,ylim=c(0,1))
Another discrete probability distribution is that of rolling a die:
die_probs <- c(1/6,1/6,1/6,1/6,1/6,1/6)
die_rolls <- c(1,2,3,4,5,6)
barplot(die_probs~die_rolls, ylim=c(0,1))
The expected value of a random variable is:
\[E(X) = x_1 \times P(X=x_1) + \dots + x_k \times P(X=x_k) = \sum_{i=1}^k x_i P(X = x_i)\]
and the standard deviation of the expected value of the random variable is
\[\sqrt{\sum (x_i-E(X))^2 P(X = x_i)}\]
If all the probabilities are the same, then \[E(X) = x_1 \times \frac{1}{k} + \dots + x_k \times \frac{1}{k} = \frac{\sum_{i=1}^k x_i}{k} = \bar{x}\]
this is just the mean.
eg. The expected price of a text book is
# This finds each book price times each probability
probs*book_prices
## [1] 0.00 75.35 42.50
# the expected value is the sum
sum(probs*book_prices)
## [1] 117.85
# the expected cost of the book is $117.85
# find the standard deviation of the price
sqrt(sum((117.85-book_prices)^2*probs))
## [1] 60.49238
When all probabilities are equally likely the distribution is called the uniform distribution.
The expected value of a random variable with a uniform probability distribution is the mean of the possibilities