Instructions: Please submit your knitted html document. This script is set to print your code (do not change the setup chunk) so there is no need to submit your .Rmd file in addition to the html.


Q1. For these three questions, consider a Normal distribution with a mean of 68.5 and a standard deviation of 15.1.

Q1a. What is the probability of values less than or equal to 20?

pnorm(20, mean = 68.5, sd = 15.1)
## [1] 0.0006592542

Q1b. What is the probability of a value within the range 70-75?

pnorm(75, mean = 68.5, sd = 15.1) -
  pnorm(70, mean = 68.5, sd = 15.1)
## [1] 0.1270058

Q1c. What value corresponds to the 99th percentile of this distribution?

qnorm(0.99, mean = 68.5, sd = 15.1)
## [1] 103.6279

Q2. Imagine a bird species with mean clutch size of 3.8 eggs per nest. Assume that egg number is Poisson-distributed.

Q2a. what is the probability of five or more eggs?

ppois(4, lambda = 3.8, lower.tail = FALSE)
## [1] 0.3321564

Q2b. What is the single most probable clutch size under this Poisson distribution?

“For a noninteger Poisson mean, the most probable count is the mean rounded down: 3 eggs.”

floor(3.8)
## [1] 3

Q2c. What is the variance of clutch size?

3.8
## [1] 3.8

Q2d. What is the smallest possible clutch size that could occur under this distribution?

0
## [1] 0

Q3a. Use rnorm() to draw 10 random values from a normal distribution with any mean and variance you wish. Call this vector of values x1. Then draw another 10 values from the same normal distribution. Call this x2. Calculate the Pearson correlation coefficient between x1 and x2.

x1 <- rnorm(10, mean = 0, sd = 1)
x2 <- rnorm(10, mean = 0, sd = 1)

cor(x1, x2, method = "pearson")
## [1] 0.03747148

Q3b. Repeat Q3a 100 times using a “for-loop”. (An example is provided below to help get you started; ask for help as needed.) Plot a histogram of these 100 correlation coefficients. What is the strongest correlation (in absolute value) you could observe simply by chance?

out <- c()

for(i in 1:100){
  x1 <- rnorm(10, mean = 0, sd = 1)
  x2 <- rnorm(10, mean = 0, sd = 1)
  out[i] <- cor(x1, x2, method = "pearson")
}

hist(out,
     main = "Correlations with 10 Values",
     xlab = "Pearson correlation coefficient",
     xlim = c(-1, 1),
     col = "lightgreen")

# Largest absolute correlation observed
max(abs(out))
## [1] 0.7902526

Q3c. Repeat Q3b but this time draw 1000 random values for x1 and x2 instead of 10. Again, plot the histogram and identify the strongest correlation you could observe by chance?

out_large <- c()

for(i in 1:100){
  x1 <- rnorm(1000, mean = 0, sd = 1)
  x2 <- rnorm(1000, mean = 0, sd = 1)
  out_large[i] <- cor(x1, x2, method = "pearson")
}

hist(out_large,
     main = "Correlations with 1,000 Values",
     xlab = "Pearson correlation coefficient",
     xlim = c(-1, 1),
     col = "lightgreen")

# Largest absolute correlation observed
max(abs(out_large))
## [1] 0.06756066

Q3d. What lesson do you take away from this exercise? “Small samples can show strong correlations simply, even when the variables are independent. Larger samples tend to produce correlations closer to zero, making strong chance correlations less likely.”