# 8/29/2022

## Discussion of R code to simulate Pi - I will ask for volunteers to discuss their code on Wed.

## Comments on your Reading Assignment

- Data science versus statistics
- Case Study - sabermetrics (Bill James)
- Money Ball (Billy Bean)
- Buffalo Bills (Dennis Lock)
- Charlotte Hornets (Alexander Powell)

- tidyverse and piping
- Questions?

## Loading packages

- mosaic and mosaicData - lots of useful tools and resources
- mdsr - resources for our textbook
- fed16 (fed, fed12, etc.) - Federal Elections Commission
- macleish - field station weather data
- IMDbPY - Python package for internet movie database
- LOTS of others (later)

## Question for the class

- For those of you with R and RStudio experience, what is one tip for new users of RStudio? That is, what is one thing that you wish you would have been told when you started using R and RStudio?

## Class Activity - Our first set of simulations

- Generate 100 uniform(0, 1) random numbers using runif().
- Summarize the distribution with a histogram. Does the shape of the distribution match what you expected?
- Comment on the center, shape, and spread.
- Use qqnorm() and qqline() to check normality.
- Use t.test to check if the random number generator matches the expected mean.
- Create a new variable y = 2x that doubles the range of simulated values
- Create a new variable that generates uniform random numbers between -3 and 3.

- Generate 100 normal(0, 1) random numbers using rnorm().
- Summarize the distribution with a histogram. Does the shape of the distribution match what you expected?
- Comment on the center, shape, and spread.
- Use qqnorm() and qqline() to check normality.
- Change the mean and standard deviation to other values of your choice. Does the shape of the quantile plot change as you change the mean and standard deviation?

- Generate 100 binomial(31, .5) random numbers using rbinom().
- Summarize the distribution with a histogram.
- Comment on the center, shape, and spread.
- Use qqnorm() and qqline() to check normality. Is the distribution approximately normal?
- Change the number of trials and the probability of success to other values of your choice. Does the shape of the distribution change as you change the values of n and p? Make sure that you try some values of p close to zero and others close to 1.

- Generate 100 geometric(1/6) random numbers using rgeom().
- Summarize the distribution with a histogram.
- Comment on the center, shape, and spread
- Use qqnorm() and qqline() to check normality. Is the distribution approximately normal?

## Please complete your reading of Appendix B and read Chapter 2 for class on Wednesday.