Normal Approximations

STAT 20: Introduction to Probability and Statistics

Agenda

  • Announcements
  • Lab 2 Issues
  • Cheat Sheet Format
  • Accomodations for Quiz
  • Review of Sampling Code
  • Lecture: Continuous Random Variables
  • Lecture: Central Limit Theorem
  • Worksheet

Lab 2 Issues

  • Lab 2 had TWO parts:
  • Part 1, 10 questions
  • Part 2, 20 Questions
  • Both need to be submitted to gradescope in a single pdf
  • ~20 students did not submit part 1.
  • I will reopen Lab 2 until start of class tomorrow to re-submit if you did not submit part 1

How to Make One PDf?

  1. Write it all in one qmd file, 30 questions, type all part 1 questions similar to part 2
  2. Merge pdf’s using software e.g. Adobe, online pdf merger
  3. Insert image into qmd file

Cheat Sheet for Quiz

  • ONE SIDED CHEAT SHEET
  • Only FRONT of a page, NOT back
  • We will confiscate any two sided cheat sheets, only one page ONLY front

Accommodations

  • If you have permission for extra time/ other accommodations, write in EVANS HALL room 493
  • Email me if you have any questions

Review: Sampling To Generate Random Numbers

  • Talking to students, it seems some are a little lost on the sample, rep, replicate function from the last lectures
  • Spend some time reviewing how to use these

Sample

Say we have a list of numbers, sample by defualt will pick one number from that list WITHOUT REPLACEMENT

my_vec <- c(-1,-1,0,1,2)
sample(my_vec, size = 1)
[1] -1

We can sample more that one time with size command, sample 3 times WITHOUT replacement,

sample(x = my_vec, size = 3)
[1] -1  0  2

Sample 20 times WITH REPLACEMENT

sample(x = my_vec, size = 20, replace = TRUE)
 [1]  0  0 -1  1 -1 -1  1  1 -1  0  1  2  1 -1  0  1 -1  0  0  1

Non Uniform Probability and rep

Say I have the following pmf,

\(X\) \(f(x)\)
\(-1\) \(4/9\)
\(0\) \(4/9\)
\(2\) \(1/9\)

How to generate a single sample?

Use the rep function vs p agrument

The rep function makes vector with a number repeated an amount of times,

rep(-1,4)
[1] -1 -1 -1 -1
  1. So, let’s make a vector with four -1’s, four 0’s, and one 2 and sample that once with uniform probability,
my_vec <- c(rep(-1,4), rep(0,4), 2)
sample(my_vec, size = 1)
[1] 0
  1. We can also pass sample a p argument of probabilities, and it will pick each option with that probability
sample(x = c(-1,0,2), p = c(4/9, 4/9, 1/9), size = 1)
[1] 0

Using Replicate

Let’s write code to sample 5 times with replacement from my previous vector and count the mean value,

my_sample <- sample(my_vec, size = 5)
mean(my_sample)
[1] -0.6

Now let’s repeat this 1000 times, so I sample 5 times, compute the mean each time, and do this 1000 times. Then let’s compute the variance of this list. Use replicate

many_samples <- replicate(1000,mean(sample(my_vec, size = 5)))
var(many_samples)
[1] 0.08375059

Lecture: Sums, Averages, and Continuous Random Variables

45:00

Lecture: Central Limit Theorem

25:00

Break:

05:00

Worksheet:

45:00