March 17, 2018
2 min read
Random variable — is a variable whose possible values are outcomes of a random experiment. For example the number of hits during the three shots(0, 1, 2, 3), or sum of the upward face after rolling 5 dice(5 … 25). This is examples of discrete random variables, variables with a fixed amount of possible values. Another type is continuous random variable — the variable that can take any value on the interval. For example, speed or mass of some random object.
import random
discrete_variable = random.choice(['head', 'tail'])
# tail
continuous_variable = random.random()
# 0.8902011603082036
Let’s take a closer look at discrete random variables. The discrete random variable has a number of possible values, each value has it is own probability. Since events are a mutually exclusive sum of all their probabilities equal to one.
A random variable will be completely described if we specify distribution — probability for each event. This way we can specify the Law of distribution of the discrete variable.
The law of distribution of a random variable is any relation that establishes a connection between the possible values of a random variable and the corresponding probabilities.
Example. Some shooter fires on the target until the first hit and he has 4 shells. Probability of hit is 0.6. We should find the distribution of unused shells.