Rebekah Robinson, Georgetown College

Always remember to make sure the necessary packages are loaded:

```
require(mosaic)
require(tigerstats)
```

The

expected valueof \( 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.

**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?

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
```

The

standard deviationof \( 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.

**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 \]

```
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
```

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.

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
```

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.

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?

A

binomial random variablecounts 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.

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

\( n=2 \)

*success*= Heads,*failure*= TailsProbability of a

*success*= \( p=0.5 \).The first toss is

*independent*of the second toss.

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

\( n=10 \)

*success*= Tails,*failure*= HeadsProbability of a

*success*= \( p=0.5 \).Tosses are

*independent*.

**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 FluProbability of a

*success*is unknown and variable.Children are

**not***independent*.

\( 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)
```

```
[1] 0.1719
```

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

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

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

```
[1] 0.05469
```

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

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

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

```
[1] 0.8281
```

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

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

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

```
[1] 0.9453
```

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

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

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

```
[1] 0.3662
```

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

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

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

```
[1] 0.2051
```

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

For a binomial random variable \( X \),

the

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

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

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
```

Part 3 will discuss continuous random variables.