Lab 04-Random Variable
Lab 04-Random Variable
Lab 04-Random Variable
1 Definitions
"Variable" is something that can be changed, "random" is unknown. Thus, "random variable" is
something that can be changed and cannot be determined what it is.
In the dice experiment, we define the random variable X = {1, 2, 3, 4, 5, 6} corresponding to the
outcome of the face 1, 2, 3, 4, 5, or 6; It is clear that the result after each experiment is not
determined (random).
• Discrete random variables: random variables are called "discrete" when their val ues are finite
or infinitely countable x1, x2, ..., xn. In other words, discrete random variables when we can list
all the values of that random variable.
• Continuous random variable: random variable is called "continuous" in a range of values if its
possible values fill that value range.
3 Probability distribution
A probability distribution function of a random variable is the rule that shows how to assign each
probability to each value of a random variable.
Determine the probability distribution function of the dice experiment based on experimental
results.
4 Cumulative distribution function – CDF
In probability theory, the cumulative distribution function fully describes the probability
distribution of a random variable X with real value. For each real number x, the cumulative
distribution function is defined as follows:
(1)
Calling faces 1, 2, 3 is small; faces 4, 5, 6 are big. Calculate the probability to achieve a small
result:
(2)
5.2 Variance
In probability and statistical theory, the variance of a random variable is the measure of the
statistical dispersion of that random variable, which indicates that the values of the random
variable are often how for from expected values.
(3)
The standard deviation can be calculated by taking the square root of the variance:
(4)
Determine the standard deviation of the random variable X in the dice experiment:
(4)
6 Exercises
1. The number of emergency cases in a hospital in a day is a random variable. The hospital
collected data for 10 years and saved in variable x as follows:
Know that each value in list x is the number of emergency cases in a day. For example: x = [0, 5,
2] means that the data consists of 3 days with the corresponding number of emergency cases per
day of 0, 5, 2. Write the program to execute:
(a) Determine the values of the random variable X and store it in variable X.
(b) Calculate the probability distribution function of the random variable X and store it in
variable P (list type).
2. Write a program for flipping 2 coins experiment in 10,000 times, calling X the number of
faces that appear on each roll.
(a) Save the results of flipping 2 coins into the variable x (list type). For example, x = [0,
2, 1] represents 3 times of launching, the first time no coin has a head, the second time
both of them have a head, the third time has only one head.
(c) Calculate the probability distribution function of the random variable X and store it in
variable P (list type).