When analyzing data in numerical statistics, machine learning, and other fields, you may need to obtain the average of a random variable. In particular, it is often necessary to find out the average value of a continuous random variable. It happens because in the real world, random processes are more frequently described by continuous random variables than by discrete ones. To calculate a value close to the average of a continuous random variable, you will use such a characteristic as the mathematical expectation of a continuous random variable.
Defining the expected value
You can calculate the expected value of a continuous random variable by analogy with the expected value of a discrete random variable. You might remember that to obtain the expected value of a discrete random variable that takes values from the set , you need to use the following formula:
That is, you multiply each value of a random variable by its probability and sum up all such products. Then, let be the probability density function (PDF) for the continuous random variable that takes an infinite number of possible values. You can't take the probability at the point for a continuous random variable, since it is equal to by properties. If the set of solutions is infinite, then it is almost impossible to get a probability equal to a specific value. In this case, you have to take the probability in some neighborhood of the point, for example, on the interval . It turns out that you need to calculate something like the following expression:
In turn, the probability on the interval of length is the area under the graph of the PDF , as below:
Let's approximate the probability of a point in the neighborhood: ,
You need to consider all the points where a continuous random variable is defined, as in the discrete case. Thus, let's try to reduce the length of the interval and increase the number of points to consider as many of them as possible. Visually, it will look like this:
Now you understand that if you let tend to zero, the sum will be equal to the integral in the limit. This integral is equal to the area under the graph, which you see above. This means that you need to integrate, not sum. Now let's formulate the definition of the mathematical expectation.
Definition. If is a continuous random variable with the PDF , then the expected value of is defined as:
In other words, comparing with the discrete case formula, you replaced the probability mass function with the probability density function and the sum with the integral in the formula.
All properties for the expected value of a discrete random variable are preserved for the expected value of a continuous random variable.
Examples
Let's consider a simple example. Imagine that you have a bicycle, and you are careful and afraid to damage the tire of the wheel. You are interested in where damage can happen, in what place the wheel can be pierced. First, you need to enter some kind of metric, a way to determine where the exact location of the damage is. The wheel is round and visually the same everywhere. You can take the valve stem as a starting point. Then you introduce a random variable equal to the angle formed by the damage and the valve stem of the wheel, see below:
What value can the random variable take? The wheel is round, which means any angle from 0 to 360.
It can be any angle, not only an integer, for example, 7.8 degrees. Note that there isn't any finite set or countable set of possible angles, which means that your random variable is really continuous. Now, how will you define the density function? It is simple: a uniform distribution determines the random variable. Recall that for the interval the density function is defined as follows:
What is your interval? It is an interval from to . Thus, f(x) is defined as:
Now let's calculate the expected value. Note that the function is equal to zero on the intervals (−∞,0) and (360,+∞), so the corresponding integral is equal to zero, and it makes sense to take the integral only on the interval [0,360].
is calculated like this:
Next, you should calculate the resulting integral:
You get the expected value equal to . Notice that this is really the average value on the interval .
What do you think the expected value of the uniform distribution will be in the general case? The expected value will be equal to . See how this expression appeared:
With such a distribution, you will always get the expected value equal to the average value. But you are lucky: this case is not usual, more often the expected value will be close to the average value but not equal to it.
Properties of the expected value of a continuous random variable
The properties of the expected value of a continuous random variable are essentially the same as in the case of a discrete random variable. Below is a list of them, but without too many details, since these properties should be familiar to you already.
-
If a random variable takes only one value, then its expected value is equal to that very value: .
-
The expected value is linear, regarding multiplication by a constant: .
-
The expected value is linear, regarding addition: (provided both parts are well-defined).
-
If a random variable is non-negative, then its expected value is also non-negative: .
-
The expected value is monotonous: if , then .
-
If the random variables and are independent, then (note that independence is crucial here).
Conclusion
The expected value defines a value close to the average of a random variable. You can calculate the expected value of a continuous random variable by analogy with a discrete random variable. You need to calculate the integral of the product of the probability density function and the variable on the segment . In addition, all the properties of the expected value are preserved as in the discrete case.