Random Variables, Binomial Distributions, and Probability Histograms

The outcome of a random process is not known in advance. If the quantity of interest is numerical, it can be represented by a random variable.

For example, suppose a game is played ten times and the probability of winning a small prize on each play is:\[ p=0.20. \]

One set of ten plays might produce two small prizes, while another produces four. The number of small prizes varies randomly from one set of plays to another.

Define:\[ X=\text{number of small prizes in ten plays}. \]

Then \(X\) is a random variable.

What Is a Random Variable?

A random variable assigns a numerical value to every outcome of a random process.

For ten trials, let:\[ X=\text{number of successes}. \]

The possible values are:\[ X\in\{0,1,2,\ldots,10\}. \]

Before the trials occur, the value of \(X\) is unknown. After the trials, one value is observed.

For example:\[ X=2 \]

means exactly two successes occurred.

Uppercase and Lowercase Notation

Random variables are usually represented by uppercase letters:\[ X,\quad Y,\quad Z. \]

A particular possible or observed value is commonly represented by a lowercase letter:\[ x,\quad y,\quad z. \]

Thus:\[ P(X=x) \]

means the probability that random variable \(X\) takes the value \(x\).

For example:\[ P(X=2) \]

is the probability of exactly two successes.

The uppercase \(X\) represents the uncertain quantity. The value 2 is one possible realization.

Discrete and Continuous Random Variables

Random variables can be divided into two broad types.

Discrete random variables

A discrete random variable takes values from a finite or countably infinite set.

Examples include:

  • number of successes;
  • number of defective products;
  • number of customers arriving;
  • number of positive test results;
  • number of emails classified as spam.

The count \(X\) in the game example is discrete.

Continuous random variables

A continuous random variable can take any value within an interval.

Examples include:

  • height;
  • temperature;
  • time;
  • distance;
  • weight.

Discrete variables use probability masses at individual values. Continuous variables use probability densities over intervals.

The Binomial Random Variable

Suppose:

  1. the number of trials is fixed at \(n\);
  2. each trial has success or failure as its two categories;
  3. trials are independent;
  4. success probability \(p\) is constant.

If \(X\) counts the number of successes, then:\[ \boxed{ X\sim\operatorname{Binomial}(n,p) } \]

For the game example:\[ n=10 \]

and:\[ p=0.20. \]

Therefore:\[ \boxed{ X\sim\operatorname{Binomial}(10,0.20) } \]

The Binomial Probability Mass Function

For:\[ X\sim\operatorname{Binomial}(n,p), \]

the probability of exactly \(k\) successes is:\[ \boxed{ P(X=k) = \binom{n}{k} p^k(1-p)^{n-k} } \]

for:\[ k=0,1,\ldots,n. \]

This function assigns a probability to every possible value of \(X\). It is called a probability mass function, abbreviated PMF.

We may write:\[ p_X(k)=P(X=k). \]

The subscript identifies which random variable is being described.

Example: Exactly Two Successes

For:\[ X\sim\operatorname{Binomial}(10,0.20), \]

the probability of exactly two successes is:\[ P(X=2) = \binom{10}{2} (0.20)^2 (0.80)^8. \]

Since:\[ \binom{10}{2}=45, \]

we obtain:\[ P(X=2) = 45(0.20)^2(0.80)^8. \]

Therefore:\[ P(X=2) \approx0.30199. \]

As a percentage:\[ \boxed{ P(X=2)\approx30.2\% } \]

The Complete Binomial Distribution

A probability distribution specifies the probabilities of every possible value.

For:\[ X\sim\operatorname{Binomial}(10,0.20), \]

the distribution is:

\(x\)\(P(X=x)\)Percentage
00.10737410.7374%
10.26843526.8435%
20.30199030.1990%
30.20132720.1327%
40.0880808.8080%
50.0264242.6424%
60.0055050.5505%
70.0007860.0786%
80.0000740.0074%
90.0000040.0004%
100.00000010.00001%

The most likely value is:\[ X=2, \]

with probability approximately 30.2%.

Properties of a Probability Mass Function

A valid discrete probability mass function must satisfy two conditions.

Every probability is nonnegative

\[ P(X=x)\geq0. \]

All probabilities sum to one

\[ \boxed{ \sum_xP(X=x)=1 } \]

For the binomial distribution:\[ \sum_{k=0}^{n} \binom{n}{k} p^k(1-p)^{n-k} = 1. \]

This follows from the binomial theorem:\[ (p+(1-p))^n=1^n=1. \]

The Probability Histogram

A probability histogram displays the theoretical probability distribution of a discrete random variable.

For each possible value \(x\):

  • the horizontal axis shows \(x\);
  • the vertical axis shows \(P(X=x)\);
  • the corresponding bar represents the probability mass.

For the game example, the shape is approximately:

Probability
0.30 | █
0.25 | █ █
0.20 | █ █ █
0.15 | █ █ █
0.10 | █ █ █ █
0.05 | █ █ █ █ █
0.00 +------------------------------------
0 1 2 3 4 5 6 7 ...
Number of successes

The bar at \(x=2\) has height:\[ P(X=2)\approx0.302. \]

Bar Height and Probability

For a discrete probability histogram with unit-width bars centered at integer values, each bar’s area equals its probability.

If the width is 1:\[ \text{Area} = \text{height}\times1 = P(X=x). \]

It is also common to interpret the displayed height directly as the probability mass.

Because the variable is discrete, bars are often separated by small gaps to emphasize that values such as:\[ 1.5 \]

are not possible outcomes for a count.

Theoretical Probability Versus Observed Data

A probability histogram describes a theoretical random process. It does not require that the process has already been observed.

For:\[ X\sim\operatorname{Binomial}(10,0.20), \]

the probability histogram is computed from:

  • \(n=10\);
  • \(p=0.20\);
  • the binomial model assumptions.

It shows what the model predicts before any particular set of trials is observed.

A data histogram, in contrast, summarizes measurements that were actually collected.

Probability Histogram Versus Data Histogram

FeatureProbability histogramData histogram
SourceProbability modelObserved sample
Vertical quantityProbability mass or densityObserved count, proportion, or density
RandomnessFixed once the model is specifiedChanges from sample to sample
PurposeDescribe theoretical possibilitiesSummarize collected data
TotalProbabilities sum to 1Observed proportions sum to 1
ExampleBinomial probabilitiesRecorded counts from repeated studies

The two graphs may look similar, but they answer different questions.

Repeated Data Approach the Theoretical Distribution

Suppose the ten-play process is repeated many times. Each repetition produces one observed value of \(X\).

For example:\[ 2,1,3,0,2,2,4,1,\ldots \]

An empirical frequency table can be constructed:\[ \hat{P}(X=x) = \frac{ \text{number of repetitions producing }x }{ \text{total number of repetitions} }. \]

As the number of repetitions increases, these empirical proportions should approach the theoretical binomial probabilities under a correct and stable model:\[ \hat{P}(X=x)\rightarrow P(X=x). \]

Thus, the observed histogram tends to resemble the probability histogram in the long run.

One Observation Does Not Form a Distribution

If the game is played ten times once and produces:\[ X=4, \]

only one realization has been observed.

This does not mean:\[ P(X=4)=1. \]

It means the realized value was 4.

The probability distribution describes the uncertainty before observation and the long-run variation across repeated sets of ten trials.

The realized value and its probability are different concepts.

Expected Value of a Random Variable

The expected value is the probability-weighted average of all possible values.

For a discrete random variable:\[ \boxed{ E[X] = \sum_xxP(X=x) } \]

For a binomial random variable:\[ \boxed{ E[X]=np } \]

In the game example:\[ E[X] = 10(0.20) = 2. \]

The expected number of successes is two.

This does not mean every set of ten trials produces two successes. The probability table shows:\[ P(X=2)\approx0.302. \]

Approximately 69.8% of repetitions produce a value other than 2.

Expected value is a long-run average, not a guaranteed outcome.

Variance and Standard Deviation

The variance of a discrete random variable is:\[ \boxed{ \operatorname{Var}(X) = E[(X-E[X])^2] } \]

For a binomial random variable:\[ \boxed{ \operatorname{Var}(X)=np(1-p) } \]

and:\[ \boxed{ \operatorname{SD}(X) = \sqrt{np(1-p)} } \]

For:\[ X\sim\operatorname{Binomial}(10,0.20), \]

the variance is:\[ \operatorname{Var}(X) = 10(0.20)(0.80) = 1.6. \]

The standard deviation is:\[ \operatorname{SD}(X) = \sqrt{1.6} \approx1.265. \]

Thus, the count varies around its mean of 2 with a standard deviation of approximately 1.27.

Shape of the Binomial Distribution

The shape depends on \(n\) and \(p\).

When \(p=0.5\)

The distribution is symmetric:\[ P(X=k)=P(X=n-k). \]

When \(p<0.5\)

The distribution is generally right-skewed, especially when \(np\) is small.

Most probability lies near smaller counts, with a tail extending toward larger counts.

When \(p>0.5\)

The distribution is generally left-skewed.

Most probability lies near larger counts, with a tail extending toward smaller counts.

As \(n\) increases

If \(p\) is not too close to 0 or 1, the shape becomes increasingly bell-like.

For:\[ n=10,\qquad p=0.20, \]

the distribution is right-skewed because the expected count is relatively small:\[ np=2. \]

The Mode of a Binomial Distribution

The most probable count is called the mode.

For a binomial distribution, a mode is typically:\[ \left\lfloor(n+1)p\right\rfloor, \]

unless \((n+1)p\) is an integer, in which case two adjacent modes occur.

For:\[ n=10 \]

and:\[ p=0.20, \]

we have:\[ (n+1)p=11(0.20)=2.2. \]

Therefore:\[ \lfloor2.2\rfloor=2. \]

This agrees with the probability histogram: \(X=2\) has the tallest bar.

Cumulative Probabilities

A probability histogram can also answer questions involving ranges.

At most two successes

\[ P(X\leq2) = P(X=0)+P(X=1)+P(X=2). \]

Therefore:\[ P(X\leq2) \approx 0.107374+0.268435+0.301990. \]

Thus:\[ \boxed{ P(X\leq2)\approx0.6778 } \]

More than two successes

\[ P(X>2) = 1-P(X\leq2). \]

Therefore:\[ P(X>2) \approx1-0.6778 = 0.3222. \]

Between one and four successes

\[ P(1\leq X\leq4) = \sum_{x=1}^{4}P(X=x). \]

On the probability histogram, this is represented by the combined area of the bars at 1, 2, 3, and 4.

The Cumulative Distribution Function

For any random variable \(X\), the cumulative distribution function is:\[ \boxed{ F_X(x)=P(X\leq x) } \]

For a discrete variable, the CDF increases in steps.

For example:\[ F_X(2)=P(X\leq2)\approx0.6778. \]

The CDF is useful for calculating:

  • at most;
  • no more than;
  • below or equal to;
  • percentile cutoffs.

Right-tail probabilities can be found using:\[ P(X>x)=1-F_X(x). \]

Probability Mass Function Versus Cumulative Distribution

FunctionDefinitionQuestion answered
PMF\(p_X(x)=P(X=x)\)What is the probability of exactly \(x\)?
CDF\(F_X(x)=P(X\leq x)\)What is the probability of at most \(x\)?

For the game:\[ p_X(2)\approx0.3020 \]

but:\[ F_X(2)\approx0.6778. \]

The first includes only two successes. The second includes zero, one, and two successes.

Simulating the Random Variable

A binomial random variable can be simulated by repeating Bernoulli trials:

import random
def simulate_binomial(number_of_trials, success_probability):
successes = 0
for _ in range(number_of_trials):
if random.random() < success_probability:
successes += 1
return successes
result = simulate_binomial(10, 0.20)
print(result)

Each call returns one possible realization such as:

1

or:

4

Repeating the simulation many times creates an empirical distribution that can be compared with the theoretical binomial probability histogram.

Model Assumptions Still Matter

The theoretical distribution:\[ X\sim\operatorname{Binomial}(10,0.20) \]

is valid only if:

  • there are exactly ten trials;
  • each trial can be classified as success or failure;
  • success probability remains 0.20;
  • trials are independent.

If these assumptions fail, the theoretical bars may not match observed frequencies.

For example:

  • a changing \(p\) can alter the shape;
  • dependence can increase or decrease variability;
  • an incorrect success definition changes the model;
  • data errors can distort the empirical comparison.

A probability distribution is a model of the process, not an automatic truth.

Common Mistakes

Confusing \(X\) with \(P(X=x)\)

\(X\) is a random variable. \(P(X=x)\) is a probability.

Treating the expected value as the most certain outcome

The mean may not even be a possible observed value, and it need not be the mode.

Treating one realization as the distribution

One observed count does not reveal all possible probabilities.

Calling a probability histogram observed data

Its bar heights come from a theoretical model.

Assuming observed frequencies must equal theoretical probabilities

Finite samples fluctuate randomly.

Forgetting that all probability masses sum to one

If they do not, the proposed PMF is invalid.

Using the binomial distribution without checking assumptions

Fixed trials, binary classification, constant \(p\), and independence are required.

Assuming bar height always means probability

The meaning of the vertical axis must be read from the graph. A data histogram may display counts, proportions, or density instead.

A Reliable Interpretation Process

When working with a discrete random variable:

  1. Define the random process.
  2. Define what the random variable measures.
  3. List its possible values.
  4. identify its probability distribution.
  5. Verify the model assumptions.
  6. calculate or display \(P(X=x)\).
  7. Check that probabilities sum to one.
  8. distinguish theoretical probabilities from observed proportions.
  9. calculate expected value and standard deviation when useful.
  10. Interpret results in the original context.

Key Takeaway

A random variable assigns a numerical value to the outcome of a random process. If \(X\) counts successes across ten independent trials with success probability 0.20, then:\[ X\sim\operatorname{Binomial}(10,0.20). \]

Its probability mass function assigns probabilities such as:\[ P(X=2)\approx30.2\%. \]

A probability histogram visualizes these theoretical probabilities. It differs from a data histogram, which summarizes observations that were actually collected. Repeated empirical data may approach the theoretical distribution, but any individual sample remains subject to random variation.

Similar Posts

Leave a Reply