4-2. Probability Distributions for Discrete Random Variables

离散随机变量的概率分布

1. Probability Distributions

The probability distribution of a discrete random variable X is a list of each possible value of X together with the probability that X takes that value in one trial of the experiment.

The probabilities (Probability Mass Function) in the probability distribution of a random variable XX must satisfy the following two conditions:

  1. Each probability P(x)P(x) must be between 0 and 1: 0P(x)10≤P(x)≤1 .

  2. The sum of all the probabilities is 1 : ΣP(x)=1.ΣP(x)=1.

EXAMPLE 1. A fair coin is tossed twice. Let XX be the number of heads that are observed.

  1. Construct the probability distribution of XX .

  2. Find the probability that at least one head is observed. P(X1)P(X \ge 1)

[ Solution ]

library(Rstat)

# 0. Sample Space
S <- tosscoin2(2); S 

# 1. Define X
# 1-1. define function to count the number of Heads
countH <- function(x) sum(x=="H")

# 1-2. Define X
X <- apply(S, 1, countH)

# 2. Prob. Distribution Table
y <- table(X) / nrow(S)

# 3. plot table
barplot(y)

EXAMPLE 2. A pair of fair dice is rolled. Let XX denote the sum of the number of dots on the top faces.

  1. Construct the probability distribution of XX .

  2. Find P(X9)P(X ≥ 9) .

  3. Find the probability that XX takes an even value.

[ Solution ]

library(Rstat)

# probability distribution of X
rolldie.sum(2)

The Mean and Standard Deviation of a Discrete Random Variable

The mean (also called the expected value) of a discrete random variable X is the number

μ=E(X)=ΣxP(x)μ=E(X)=Σx P(x)

The mean of a random variable may be interpreted as the average of the values assumed by the random variable in repeated trials of the experiment.

EXAMPLE 3. Find the mean of the discrete random variable XX whose probability distribution is

x       -2    1    2  3.5
P(x)  0.21 0.34 0.24 0.21

[ Solution ]

library(Rstat)

x <- c(-2, 1, 2, 3.5)
px <- c(0.21, 0.34, 0.24, 0.21)

mean <- sum(x * px) ; mean

# disc.exp(x, p) : E(X), V(X), Std Dev(X)
disc.exp(x, px)

# Draw the graph
disc.exp(x, px, prt=FALSE, plot=TRUE)

EXAMPLE 4. A service organization in a large town organizes a raffle each month. One thousand raffle tickets are sold for $1 each. Each has an equal chance of winning. First prize is $300, second prize is $200, and third prize is $100. Let XX denote the net gain from the purchase of one ticket.

  1. Construct the probability distribution of XX .

  2. Find the probability of winning any money in the purchase of one ticket.

  3. Find the expected value of XX , and interpret its meaning.

[ Solution ]

library(Rstat)

x <- c(299, 199, 99, -1)
px <- c(0.001, 0.001, 0.001, 0.997)

# 2.
sum(px[1:3])

# 3.
sum(x * px)

# E(X), V(X), Std Dev(X)
disc.exp(x, px)

# Draw the graph
disc.exp(x, px, prt=FALSE, plot=TRUE)

EXAMPLE 5. A life insurance company will sell a $200,000 one-year term life insurance policy to an individual in a particular risk group for a premium of $195. Find the expected value to the company of a single policy if a person in this risk group has a 99.97% chance of surviving one year.

[ Solution ]

library(Rstat)

x <- c(195, -199805)
px <- c(0.9997, 0.0003)

# 2.
sum(x * px)

# E(X), V(X), Std Dev(X)
disc.exp(x, px)

# Draw the graph
disc.exp(x, px, prt=FALSE, plot=TRUE)

The variance, σ2σ^2 , of a discrete random variable X is the number

σ2=Σ(xμ)2P(x)σ^2=Σ(x−μ)^2 P(x)

which by algebra is equivalent to the formula

σ2=Σ(x2P(x))μ2σ^2= Σ(x^2* P(x))−μ^2 .

The standard deviation, σσ , of a discrete random variable X is the square root of its variance, hence is given by the formulas

σ=Σ(xμ)2P(x)=Σx2P(x)μ2σ=\sqrt{Σ(x−μ)^2 P(x)} = \sqrt{Σx^2 P(x) − μ^2}

EXAMPLE 6. A discrete random variable X has the following probability distribution:

x      -1    0  1    4
P(x)  0.2  0.5  a  0.1

Compute each of the following quantities.

  1. a.

  2. P(0)P(0)

  3. P(X>0)P(X > 0) .

  4. P(X0)P(X ≥ 0) .

  5. P(X2)P(X≤−2) .

  6. The mean μ μ of XX .

  7. The variance σ2σ^2 of XX .

  8. The standard deviation σσ of XX .

[ Solution ] which()

library(Rstat)

# 1. a
a <- 1 - sum(0.2, 0.5, 0.1); a
x <- c(-1, 0, 1, 4)
px <- c(0.2, 0.5, a, 0.1)


# 2. P(0)
px[which(x==0)]

# 3. P(X>0)
sum(px[which(x>0)])

# 4. P(X>=0)
sum(px[which(x>=0)])

# 5. P(X<=-2)
sum(px[which(x<=-2)])

# 6.
mean <- sum(x*px) ; mean

# 7.
variance <- sum(x^2*px) - mean^2 ; variance

# 8.
std <- srqt(variance) ; std

# E(X), V(X), Std Dev(X)
disc.exp(x, px)

# Draw the graph
disc.exp(x, px, prt=FALSE, plot=TRUE)

概率质量函数 Probability Mass Function 期望值 Expected Value

Last updated