Basic Probability (Part 2)

Rebekah Robinson, Georgetown College

In Part 2:

Load Packages

Always remember to make sure the necessary packages are loaded:

require(mosaic)
require(tigerstats)

Expectation

Expected Value

The expected value of \( X \) is the value of \( X \) that we would expect to see if we repeated the experiment many times.

Expected value is a weighted average.

\[ EV(X)=\sum x\cdot P(X=x) \]

  • Multiply every value in the range of \( X \) by it's corresponding probability.

  • Sum these products.

Expected Value: An Example

Example: \( X= \) number of heads in two tosses of a fair coin.

The most likely value of \( X \) is 1.

What value do we expect \( X \) to be?

plot of chunk unnamed-chunk-4

Example (cont'd)

  • Range of \( X = \{0,1,2\} \).

  • \( P(X=0)=0.25 \), \( P(X=1)=0.50 \), \( P(X=2)=0.25 \)

\[ EV(X)=0(0.25) + 1(0.50) + 2(0.25)=1 \]

x<-c(0,1,2)
prob.x<-c(0.25,0.50,0.25)
EV.X<-sum(x*prob.x)
EV.X
[1] 1

Standard Deviation

The standard deviation of \( X \) is a measure of how much \( X \) is expected to differ from \( EV(X) \).

\[ SD(X)=\sqrt{\sum(x-E(X))^2\cdot P(X=x)} \]

  • Find the difference between every value in the range of \( X \) and \( EV(X) \).

  • Square the differences.

  • Multiply the squares by the corresponding probability.

  • Sum the products. Take the square root.

Standard Deviation: An Example

Example: \( X= \) number of heads in two tosses of a fair coin.

  • Range of \( X=\{0,1,2\} \).

  • \( P(X=0)=0.25 \), \( P(X=1)=0.50 \), \( P(X=2)=0.25 \)

  • \( EV(X)=1 \)

\[ SD(X)=\sqrt{(0-1)^2(0.25)+(1-1)^2(0.5)+(2-1)^2(0.25)}\approx 0.707 \]

Example (cont'd)

x<-c(0,1,2)
prob.x<-c(0.25,0.50,0.25)
EV.X<-sum(x*prob.x)
SD.X<-sqrt(sum((x-EV.X)^2*prob.x))
SD.X
[1] 0.7071

Evaluating a Game

Expected value and standard deviation work together to describe how a random variable is likely to turn out.

Example: Suppose you make a $100 bet. You have two options: Bet 1 and Bet 2.

  • Let \( X= \) net gain from making Bet 1.

  • Let \( Y= \) net gain from making Bet 2.

Evaluating a Game (cont'd)

PDF for Bet 1

\( x \) $5,000 $1,000 $0
\( P(X=x) \) 0.001 0.005 0.994
x<-c(5000,1000,0)
prob.x<-c(0.001,0.005,0.994)
EV.X<-sum(x*prob.x)
EV.X
[1] 10

PDF for Bet 2

\( y \) $20 $10 $4
\( P(Y=y) \) 0.30 0.20 0.50
y<-c(20,10,4)
prob.y<-c(0.3,0.2,0.5)
EV.Y<-sum(y*prob.y)
EV.Y
[1] 10

Evaluating a Game (cont'd)

Both bets have the same expected net gain.

Standard Deviation for Bet 1:

x<-c(5000,1000,0)
prob.x<-c(0.001,0.005,0.994)
EV.X<-sum(x*prob.x)
SD.X<-sqrt(sum((x-EV.X)^2*prob.x))
SD.X
[1] 172.9

The expected net gain for Bet 1 is $10 give or take $172.90.

Evaluating a Game (cont'd)

Standard Deviation for Bet 2:

y<-c(20,10,4)
prob.y<-c(0.3,0.2,0.5)
EV.Y<-sum(y*prob.y)
SD.Y<-sqrt(sum((y-EV.Y)^2*prob.y))
SD.Y
[1] 6.928

The expected net gain for Bet 2 is $10 give or take $6.93.

Which bet would you make?

Binomial Random Variable

Special Type of Discrete Random Variable

A binomial random variable counts how often an event occurs in a given number of tries.

  • The specified number of tries, \( n \), is referred to as the \( size \).

  • Each try results in a success or a failure.

  • Each try has the same probability of success, \( p \).

  • The outcome of one try does not affect the outcome of another. The tries are independent of each other.

Binomial Random Variable: Example 1

Example: \( X= \) number of heads in two tosses of a fair coin.

  • \( n=2 \)

  • success = Heads, failure = Tails

  • Probability of a success = \( p=0.5 \).

  • The first toss is independent of the second toss.

Binomial Random Variable: Example 2

Example: \( Y= \) number of tails in 10 tosses of a fair coin.

  • \( n=10 \)

  • success = Tails, failure = Heads

  • Probability of a success = \( p=0.5 \).

  • Tosses are independent.

Binomial Random Variable: Non-Example

Example: \( Z \)= number of children who will get the flu this winter in a kindergarten class with 20 children.

  • \( n=20 \)

  • success=Flu, failure = No Flu

  • Probability of a success is unknown and variable.

  • Children are not independent.

Less Than or Equal To

\( Y= \) number of heads in 10 tosses of a fair coin

Calculating probabilities for \( Y \) is easy.

To find \( P(Y\leq 3) \):

pbinomGC(3,region="below",size=10,
         prob=0.5,graph=TRUE)

Less Than or Equal To

plot of chunk unnamed-chunk-12

[1] 0.1719

\[ P(Y\leq 3)=0.1719 \]

Less Than

To find \( P(Y< 3) \):

pbinomGC(2,region="below",
         size=10,prob=0.5,graph=TRUE)

Less Than

plot of chunk unnamed-chunk-14

[1] 0.05469

\[ P(Y< 3)=0.05469 \]

Binomial Probabilities (Greater Than)

To find \( P(Y>3) \):

pbinomGC(3,region="above",size=10,
         prob=0.5,graph=TRUE)

Binomial Probabilities (Greater Than)

plot of chunk unnamed-chunk-16

[1] 0.8281

\[ P(Y>3)=0.8281 \]

Greater Than or Equal To

To find \( P(Y\geq 3) \):

pbinomGC(2,region="above",size=10,
         prob=0.5,graph=TRUE)

Greater Than or Equal To

plot of chunk unnamed-chunk-18

[1] 0.9453

\[ P(Y\geq 3)=0.9453 \]

Between

To find \( P(2\leq Y \leq 4) \):

pbinomGC(c(2,4),region="between",
         size=10,prob=0.5,graph=TRUE)

Between

plot of chunk unnamed-chunk-20

[1] 0.3662

\[ P(2\leq Y \leq 4)=0.3662 \]

Equal To

To find \( P(Y = 4) \):

pbinomGC(c(4,4),region="between",
         size=10,prob=0.5,graph=TRUE)

Equal To

plot of chunk unnamed-chunk-22

[1] 0.2051

\[ P(Y=4)=0.2051 \]

Binomial Random Variable: EV and SD

For a binomial random variable \( X \),

  • the expected value is \( EV(X)=np \)

  • the standard deviation if \( SD(X)=\sqrt{np(1-p)} \)

EV and SD

For \( Y= \) the number of heads in 10 tosses of a fair coin:

  • \( n=10 \)

  • \( p=0.5 \)

  • \( EV(Y)=10(0.5)=5 \)

  • \( SD(Y)=\sqrt{10(0.5)(1-0.5)}\approx 1.581 \)

sqrt(10*0.5*(1-0.5))
[1] 1.581

Next Topic

Part 3 will discuss continuous random variables.