outcome_A <- sample(LETTERS, 1)

outcome_A <- sample(LETTERS, 1)

`sample`

probabilities- There are many random processes where all the possible outcomes are equally likely.

`sample`

probabilitiesThere are many random processes where all the possible outcomes are equally likely.

In these settings, \[ P(\text{Outcome}) = \frac{1}{\text{number of possible outcomes}} \]

`sample`

probabilitiesThere are many random processes where all the possible outcomes are equally likely.

In these settings, \[ P(\text{Outcome}) = \frac{1}{\text{number of possible outcomes}} \]

Example:

\[ P(\text{Randomly selected letter from English alphabet}) = \frac{1}{\text{26}} \]

`sample`

probabilitiesThere are many random processes where all the possible outcomes are equally likely.

Informally, outcomes of this type are often called

`sample`

outcomes or`urn`

outcomes.More formally, outcomes of this type are sometimes called

`discrete uniform`

random variables.

`sample`

probabilitiesThere are many random processes where all the possible outcomes are equally likely.

Informally, outcomes of this type are often called

`sample`

outcomes or`urn`

outcomes.More formally, outcomes of this type are sometimes called

`discrete uniform`

random variables.

`sample`

probabilities- There are many random processes where the possible outcomes are constructed from a sequence of
`urn`

outcomes (or`discrete uniform`

random variables).

`sample`

probabilities- There are many random processes where the possible outcomes are constructed from a sequence of
`urn`

outcomes (or`discrete uniform`

random variables).

three_letter_word <- c( sample(LETTERS, 1) , sample(LETTERS, 1) , sample(LETTERS, 1) ) three_letter_word

[1] “D” “T” “B”

- What is the probability that the sequence of outcomes spells “TOM”?

`sample`

probabilities- There are many random processes where the possible outcomes are constructed from a sequence of
`urn`

outcomes (or`discrete uniform`

random variables).

three_letter_word <- c( sample(LETTERS, 1) , sample(LETTERS, 1) , sample(LETTERS, 1) )

- What is the probability that the sequence of outcomes spells
`TOM`

?

`sample`

probabilities- What if

another_three_letter_word <- sample(LETTERS, 3)

What is the probability that `another_three_letter_word = TOM`

?

In order to calculate

\[ \begin{array}{l} P(\texttt{three_letter_word = TOM}) = \\ \phantom{ = }\phantom{ = } \frac{1}{\text{Number of 3 letter sequences}} \end{array} \]

we need need to calculate the number of 3 letter sequences.

three_letter_word <- c( sample(LETTERS, 1) , sample(LETTERS, 1) , sample(LETTERS, 1) )

another_three_letter_word <- sample(LETTERS, 3)

Is the outcome `TOM`

the same as `MOT`

or `OTM`

?

Is the outcome `TOM`

the same as `MOT`

or `OTM`

?

**Sequence:** Order matters `TOM`

\(\neq\) `MOT`

**Hand:** Order doesn’t matter `TOM`

= `MOT`

A systematic way to write out all sequences.

\[ \underbrace{N \times N \times \cdots \times N}_{K \text{ draws}} = N^K \]

\[ \underbrace{N \times (N-1) \times \cdots \times (N-K+1)}_{K \text{ draws}} = \frac{N!}{(N-K)!} \]

\[N! = N\times(N-1)\times(N-2)\times \cdots \times 3 \times 2 \times 1\]

\[ 5! = 5 \times 4 \times 3 \times 2 \times 1\]

In R:

factorial(5)

## [1] 120

**Note**

\[ 0! = 1 \]

- Total number of sequences is \(N^K\) when drawing with replacement
- Total number of sequences is \(N!/(N-K)!\) when drawing with
**out**replacement

- In a
**sequence**of draws, order matters:

\[ABC \neq CAB\]

- In a
**hand**(or sample) of draws, order does**NOT**matter:

\[ABC = CAB\]

Go back to all the sequences:

- For each
**hand**there are a certain number of duplicate**sequences**

- For each
**hand**, how many**sequences**are there?

- For each
**hand**, how many**sequences**are there? **Hint**: Think of the hand as a mini deck.

- For each
**hand**, how many**sequences**are there? **Hint**: Think of the hand as a mini deck.- How many
**sequences**of \(K\) cards from a deck of \(K\) cards are there, with**out**replacement?

- For each
**hand**, how many**sequences**are there? **Hint**: Think of the hand as a mini deck.- How many
**sequences**of \(K\) cards from a deck of \(K\) cards are there, with**out**replacement? - \(K\times(K-1)\times \cdots \times 2 \times 1\)

- \(K\) cards from \(N\) with
**out**replacement has \(N!/(N-K)!\) possible**sequences** - For each
**hand**there are \(K!\)**sequences**(The hand to sequence multiplier)

- To get the number of
**hands**, divide the number of sequences by the multiplier.

\[\frac{\text{Number sequences}}{\text{hand to sequence multiplier}} = \frac{\frac{N!}{(N-K)!}}{K!} = \frac{N!}{(N-K)!K!} \]

\[ {N \choose K} = \frac{N!}{(N-K)!K!} \]

The number of hands of size \(K\) from a deck of \(N\) cards when drawing with**out** replacement.

In R

#The number of 5 card hands from a 52 card deck choose(52,5)

## [1] 2598960

A process or experiment that generates a binary outcome (0 or 1; heads or tails; success or failure)

Successive replications of the process are independent

The probability \(P(outcome = 1)\) is constant

**Notation:**- \(p = P(outcome = 1)\)
- \(q = (1-p) = P(outcome = 0)\)

\[ Success,\ Success,\ Failure,\ Success\] \[ 1,\ 0,\ 1,\ 1,\ 1,\ 0 \] \[tails,\ tails,\ tails,\ heads\]

**Note:** A Bernoulli sequence can be thought of as \(K\) draws with replacement from a deck of \(N=2\) cards.

Because successive outcomes are independent and \(p\) is constant,

\[ \begin{align*}P(1,\ 0,\ 1,\ 1,\ 1,\ 0) &= P(1)P(0)P(1)P(1)P(1)P(0) \\ & = p(1-p)ppp(1-p) \\ & = p^4(1-p)^2 \end{align*} \]

The number of successes in a Bernoulli sequence

Bernoulli properties still apply: independent outcomes, constant probability

**Notation:**- \(p\) = probability of success in a single Bernoulli replicate
- \(N\) = number of replicates in Bernoulli sequence

- For a sequence of 10 coin flips, what are the possible number of heads?

- For a sequence of 10 coin flips, what are the possible number of heads?
- 0, 1, 2, 3, …, 10

- How do we calculate P(2 heads in 4 flips)?

- How do we calculate P(2 heads in 4 flips)?
- If the sequence was \(H,\ H,\ T,\ T\), then \[P(H,\ H,\ T,\ T) = p^2(1-p)^2\]

- How do we calculate P(2 heads in 4 flips)?
- If the sequence was \(H,\ H,\ T,\ T\), then \[P(H,\ H,\ T,\ T) = p^2(1-p)^2\]
- If the sequence was \(T,\ T,\ H,\ H\), then \[P(T,\ T,\ H,\ H) = p^2(1-p)^2\]

- How do we calculate P(2 heads in 4 flips)?
- We could list all possible 4 flip sequences …

- How do we calculate P(2 heads in 4 flips)?
- We could list all possible 4 flip sequences …
- Identify all the sequences that have 2 heads …