Mon Oct 31, 2016

Recall

Recall from last lecture we studied

  • Random sampling: where we select the sample from the population in an unbiased fashion
  • Bias: A sample is biased if some observational units have a higher probability of being included in the sample.
  • Keywords: random and probability

Probability

Probability in History

In 79 AD a volcanic eruption in the Roman city of Pompeii covered the entire city in hot ash, perfectly preserving many items…

Drawing

Probability in History

… including what I saw at a Pompeii exhibit in Montreal:

Drawing

Two Approaches to Probability

There are two approaches to studying probability:

Mathematically (MATH 310) Simulations
Drawing Drawing
  • Note: The "random simulation" in question is not limited to coin flips.

Two Approaches to Probability

  • The mathematical approach to studying probability requires more mathematical background: set theory, discrete math, calculus, and later on measure theory.
  • The simulation approach does not.
  • Instead we require a computer's random number generator to generate simulations. Why?

Simulations via Computer

Doing this repeatedly by hand is tiring:

DrawingDrawingDrawingDrawingDrawingDrawingDrawing DrawingDrawingDrawingDrawingDrawingDrawingDrawing DrawingDrawingDrawingDrawingDrawingDrawingDrawing DrawingDrawingDrawingDrawingDrawingDrawingDrawing DrawingDrawingDrawingDrawingDrawingDrawingDrawing DrawingDrawingDrawingDrawingDrawingDrawingDrawing

Analogy for Random Simulation

  • Analogy for rest of course: POWERBALL
  • Drawing
  • We can model any random simulation by tinkering with the following attributes of Powerball:

Attributes of Powerball

  • Atrributes of the Lottery Machine:
    • How many balls do you have?
    • What are written on the balls?
    • Do the balls have equal probability of being picked?
  • Attributes of the Drawing:
    • How are you drawing the balls?
    • How many balls do you draw?
    • What are you recording about each drawn ball?
    • What do you do with drawn balls?
  • Number of Lotteries:
    • How many times do you repeat the lottery?

Tools

All hail the mosaic package, which is pre-installed on RStudio Server. Load as usual: library(mosaic)

The following 4 functions will give us (most of) the random simulation tools we need:

  1. rflip(): Flip a coin
  2. shuffle(): Shuffle a set of values (akin to cards)
  3. do(): Do the same thing many, many, many times
  4. resample(): the swiss army knife of functions