A parcel arrives late or on time, while the error of a temperature sensor can be any amount in a range. To compute probabilities about either one, the outcome first has to become a number, and the model then has to say how probability spreads over the possible numbers. This lesson defines random variables and three descriptions of their distributions, a mass function for values that can be listed, a density whose areas are probabilities, and a cumulative distribution function that works for both. It ends with the binomial and normal models and the assumptions behind them. All models on this page are constructed for illustration.
Key terms
Random variable
Definition A random variable is a function that assigns a real number to each outcome in the sample space . Its distribution gives the probabilities of the events it defines, such as or . The value that occurs in a particular trial is a realization of , often written in lowercase as . The variable is discrete if, with probability , its values lie in a finite or countable set, and its support is then the set of values with . It is absolutely continuous if the probabilities of intervals are areas under a density, as defined below. Some variables are neither, such as a mix of a point mass and a density, but the two kinds are enough for this lesson.
In plain words A random variable is a rule that turns an uncertain outcome into a number before the outcome is seen. The variable stands for the uncertain quantity, and a realization is the number that actually occurs. Whether to model a quantity as discrete or continuous depends on what is measured and why. A temperature error is often modeled as continuous even though a device stores it rounded.
Example For a parcel, let if it arrives late and if it arrives on time. When both cases have positive probability, the support of is . For a sensor, let be the measurement error in degrees Celsius. The constructed models below make discrete with the values , , and , continuous and uniform on the interval from to , or normal. They describe the same physical quantity under different assumptions.
Probability mass function
Definition The probability mass function, or PMF, of a discrete random variable is . It satisfies for every and
with the sum over the support, an infinite series when the support is infinite. For a set of values , the probability is the sum of over the values in . In summation notation,
with one term for each value of the index from to . The index is only a placeholder, so and are the same number.
In plain words A PMF puts a lump of probability on each possible value, and the lumps add to . The probability of an event about is the total of the lumps that the event contains. A PMF value is an actual probability, so it never exceeds .
Example The discrete sensor error has the support values and the masses in the table.
| Error in degrees | ||||
|---|---|---|---|---|
| Probability |
The masses are nonnegative and , so they form a PMF. The probability of a nonnegative error adds the masses at and , so . The value is the probability of exactly zero error in this model.
Cumulative distribution function
Definition The cumulative distribution function, or CDF, of a random variable is
for every real number . It never decreases, it tends to as and to as , and for
At each value the jump of equals . So for a discrete variable with finitely many values, is a step function that rises by at each support value and already takes the higher value at itself.
In plain words The CDF accumulates probability from the left, up to and including the threshold. Its values are probabilities, so they lie between and . For a discrete variable it matters whether an endpoint is included, because a single value can carry positive probability.
Example For the discrete sensor error , the CDF is for . It is from up to but not including , then up to , then up to , and from on. At it is still , since no support value lies between and . The interval that excludes has
while including the left endpoint gives , because the mass at is added back.
Probability density function
Definition For a nonnegative, piecewise continuous function and numbers , the definite integral
is the area of the region under the graph of and above the horizontal axis between and . When has a constant value on the region is a rectangle with area . For other shapes the area is the limit of the total area of narrow rectangles under the graph as their widths shrink to . A probability density function, or PDF, is such a function with total area under its whole graph. A random variable has density , and is absolutely continuous, if for all
Then for every single value , so including or excluding an endpoint does not change the probability of an interval, and is the area under to the left of . If carries a unit, carries the reciprocal unit, so that height times width is a pure number.
In plain words A density height is not a probability. It says how tightly probability is packed near a value, and only areas under the curve are probabilities. A density can therefore exceed , as long as the total area is . A single exact value has zero width and so zero probability, yet some value always occurs. A reading rounded to some resolution stands for a short interval of true values, and that interval can have positive probability.
Example Model the sensor error as uniform from to degrees. The width is degrees, so the constant density is per degree, which makes the total area . The probability of an error between and degrees is a rectangle area,
The density at is per degree, but . A reading of rounded to the nearest degree stands for true errors from up to , an interval with probability . Inside the support the CDF is , so .
Binomial distribution
Definition A Bernoulli random variable takes the value with probability and the value with probability , where . The value is called a success, whatever the event coded means. Let count the successes in a fixed number of Bernoulli trials that are independent and share the same success probability . Then has the binomial distribution with parameters and , and for
where the binomial coefficient counts the ways to choose which of the trials are successes, and the convention applies when is or . A categorical distribution extends the Bernoulli model to one of named categories, with probabilities that are nonnegative and sum to .
In plain words A binomial count adds up independent yes or no trials that all have the same chance. Each arrangement of successes among trials has the same probability, and the binomial coefficient counts the arrangements. The model fails when the trials are linked, for example by shared weather, or when their chances differ, even though counting the successes still makes sense. A categorical variable such as a service type names alternatives, and coding them as , and does not make the gaps between the codes meaningful.
Example Each of parcels is late with probability , independently of the others. Writing L for late and O for on time, exactly two parcels are late in the three arrangements LLO, LOL and OLL. Each has probability , so . The full PMF is
| Late parcels | ||||
|---|---|---|---|---|
and its four values sum to . A service type that is economy, express or pickup with probabilities , and follows a categorical distribution.
Normal distribution
Definition For a real number and a number , a random variable has the normal distribution with mean and standard deviation , written , if it has the density
for every real . The number is the signed distance from to in units of . The density is symmetric about , highest at with height , and positive on the whole real line. The CDF has no formula in elementary functions, so interval probabilities come from software or tables. About of the probability lies within one of , about within two and about within three. The parameters and are the mean and standard deviation of the distribution, quantities defined through expectation in the next lesson.
In plain words A normal model is a symmetric bell centered at , and sets its width. It gives some probability to every interval, however far from the center, so it can be a poor model for a quantity with hard limits or with heavier tails. It is a useful approximation in many settings, but it remains an assumption, and data that look roughly symmetric do not prove it.
Example Model the sensor error as normal with and degree. The peak density is per degree. The probability of an error between and degree, one standard deviation on each side of the mean, is an area of about . The peak height is neither that probability nor the probability of an error of exactly , which is . Unlike the uniform model on , this model allows errors larger than degree in size, with total probability about .
Check yourself
- A discrete random variable takes the values , , and with probabilities , , and . Find , the CDF value and .
Show the answer
The interval from to with both ends included contains the support values and , so . The CDF at includes the values and , so . The mass at is not included, because exceeds . Above the only support value is , so , which matches . A tempting shortcut fails here, since leaves out the mass at . The correct difference is , because no support value lies between and .
- A random variable is uniform on . Find its density, and . A classmate says a density value of is impossible, because probabilities cannot exceed . What is wrong with the argument?
Show the answer
The support has width , so the density is on and elsewhere. The interval from to has width , so its probability is the rectangle area . A single point has zero width, so , even though the density there is . The classmate treats a density height as a probability. Only areas under a density are probabilities, and here the total area is , as it must be.
- Four parcels are each late with probability . Assuming independence, find the probability that exactly one is late and the probability that at least one is late. Then suppose instead that all four ride on one truck, which is late with probability and makes every parcel late when it is late and every parcel on time otherwise. Is the number of late parcels still binomial, and what is the probability that at least one is late?
Show the answer
Under independence the count is binomial with and . Then
and the complement of no late parcel gives .
With the shared truck, each parcel is still late with probability , but the four trials are not independent. The count is with probability and with probability , so it is not binomial, and . Equal success probabilities are not enough. The binomial formula also needs independent trials.