Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##### R Project 4: Normal Distribution
- ##### Name:
- ##### Version Number:
- #############################
- ###### PART 1 ###############
- ###### GRAPH ###############
- #############################
- ## DENSITY FUNCTION
- ## C1: Create x-values - code
- xvalues_part1 <- seq(-3.7,3.7,by = 0.01)
- ## C2: Create y-values - code
- yvalues_part1 <- dnorm(xvalues_part1, mean = 0, sd = 1)
- ## C3: Create Plot - code
- ## Remember to save your plot and also submit it to Gradescope.
- plot(xvalues_part1, yvalues_part1, type = "l", main = "Standard Normal Probability Density Function (PDF)", xlab = "Variable", ylab = "Density", col = "paleturquoise3")
- #############################
- ###### PART 1 ###############
- ###### QUESTIONS ###########
- #############################
- ## Question 4: Largest approximate y value
- # Answer: 0.398942
- largest_y_value <- dnorm(0, mean = 0, sd = 1)
- ## Question 5: Why stop at the x-values from C1 instead of something like -1 and +1?
- # Answer: There are a couple of reasons to stop at the x-values from C1 instead of something like -1 and +1. One of the reasons is that it covers more than 99.7% of the data. Another reason is that you can observe the behavior of the tails.
- ## Question 6: When calculating a probability, how would this be represented on the graph?
- # Answer: If I were to calculate a probability based on this distribution, I would represent a probability based on the standard normal distribution on the standard normal probability density function graph.Particularly, I would visualize the area under the curve within a specific range of x-values.
- ## Question 7: Standard Normal Questions
- ## a) What is the mean and variance of the standard normal distribution?
- ## Mean = 0
- ## Variance = 1
- ## b) What random variable abbreviation do we usually use to represent the standard normal distribution?
- ## Answer: Z
- ## c) Based on graph in Part 1, what do the values on the horizontal axis represent?
- ## Answer: Based on graph in Part 1, the values on the horizontal axis represent z-scores.
- #############################
- ###### PART 2 ###############
- ###### GRAPH ###############
- #############################
- ## CUMULATIVE DISTRIBUTION FUNCTION
- ## X ~ N(mean = ????; variance = ????) (see PDF for mean and variance values)
- ## C8: Create x-values - code
- xvalues_part2 <- seq(410, 550, by = 7)
- ## C9: Create y-values - code
- yvalues_part2 <- pnorm(xvalues_part2, mean = 480, sd = 23, lower.tail = TRUE)
- ## C10: Create Plot - code
- plot(xvalues_part2, yvalues_part2, type = "l", main = "Normal CDF", xlab = "x-values", ylab = "P(X <= x): Cumulative Probability", col = "tomato2")
- ## C11: Cumulative Probabilities - code
- cumulative_probabilities <- c(0.17, 0.36, 0.50, 0.64, 0.83)
- ## C12: Find x-values associated with cumulative probabilities - code
- quantile_for_k <- qnorm(cumulative_probabilities)
- ## C13: Overlay points on plot - code
- points(quantile_for_k, cumulative_probabilities, pch = 24, bg = "lavenderblush3", col = "lavenderblush3")
- ## C14: Add text at each point - code
- ## Remember to save your plot and also submit it to Gradescope. <- this is the only plot from Part 2 you need to submit.
- text(quantile_for_k, cumulative_probabilities, labels = paste("(", round(quantile_for_k,2), ", ", cumulative_probabilities,")", sep = ""), pos = 4)
- #############################
- ###### PART 2 ###############
- ###### QUESTIONS ###########
- #############################
- ## Question 15: What do the y-values approach as x goes to +/- infinity?
- # As x goes towards -infinity: 0
- # As x goes towards +infinity: 1
- ## Question 16: Pick one of the points on your graph from Part 2. Write a probability statement involving the $x$- and $y$- coordinate values that describes how they relate to each other. Do not use the value corresponding to y = 0.5.
- # Point you will use: (410,0.001169302)
- pnorm(410, mean = 480, sd = 23, lower.tail = TRUE)
- # Probability Statement: y = P(X <= 410)
- ## Question 17: Create and solve your own probability problem.
- ## Must be of the form where you solve for a particular value, given the probability.
- ## Do not use any of the points from Q16.
- ## Do not use the mean value.
- ## Include your code and your final answer.
- ## Do NOT use a table or your calculator.
- # Question: P(X <= a) = 0.25. Solve for a.
- # Code:
- # Answer:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement