Random Variables, Density Functions
A random variable is formally defined as:
So, it is not a variable, but a function that maps outcomes in sample space () to real numbers.
One simple example is getting a tail when flipping a coin. It has a 50% chance, and is random.
is a package of events (, for ). Then the event properties that we have seen until now apply to random variables as well.
For example, random variables are mutually independent iff the events that they define are mutually independent for all .
Say, we flip a coin three times, and we define getting all tails as a match, which we can denote as . So, if we get tails three times, it is a match, so . If we don't get all tails, it is not a match, so .
This is a simple example that a random variable is a package of events, in this case, is our random variable.
It is also what is called the indicator variable.
An indicator variable for event is:
Let's look at some types of random variables.
A uniform random variable is when it takes values with equal probability.
An example is the outcome of rolling a fair die. The probability of each number is .
Another is binomial random variable. An example is what we get when we flip mutually independent coins (or, flipping it times). Let's assume that our coin is not fair this time, so for example, the probability of getting a head is .
Let's say that we flip the coin 5 times, and want to know the probability of getting HHTTH.
Since, the probability of getting a head is , the probability of getting a tail is going to be .
So, the probability of getting HHTTH will be .
Put it another way, .
This is also true not just this one sequence, but for each sequence with heads, and tails ( being the total number of flips).
Let denote , then the formula is:
It is the probability of a sequence of flips in which there are heads and tails.
(Any particular sequence of H's and T's of length .)
So, all sequences with the same number of H's will have the same probability.
Then, what is the probability of actually getting heads and tails in the flips?
It is simply the matter of choosing heads from number of flips. Which sounds like n choose i.
So, the probability of choosing heads and tails is:
Probability Density Function tells what's the probability that a random variable takes a given value for every possible value.
For each , it is the possibility of equals :
For example, let's think about the binomial random variable example we've just used. ( = the number of heads) is an integer from to ( = the number of flips). Of all the possible 's, the probability that the random variable equals (choosing heads) will be equal to that formula:
( is the binomial random variable that has the parameters and — as the number of flips, as the probability of getting head).
The probability density function of a uniform variable will be a constant. Probability of it taking any possible value is the same: .
Of course, it is in the range of (the range that the uniform variable takes on a value):
There is also the cumulative distribution function, defining the probability of being less than or equal to :
An example is from the practice exercises:
Let be a uniformly distributed random variable on the interval . What is the value of the Cumulative Distribution Function (CDF) at ?
Since is a uniformly distributed random variable, for .
We are looking for the probability of being less than or equal to , so from to , the first values satisfy it: .