HW10

docx

School

Temple University *

*We aren’t endorsed by this school

Course

2521

Subject

Mathematics

Date

Jan 9, 2024

Type

docx

Pages

2

Uploaded by DeanStar27858

Report
HW10 SAM SAPORITO 1. Consider figure 1. Given R code cars = c(1, 3, 6, 4, 9), figure 1 is generated using a. plot(cars, type=“p”); b. plot(cars, type=“o”); c. plot(cars, type=“l”) 2. Consider figure 2. Figure 2 is generated using a. plot(sin, -pi, pi,lty=2); b. plot(sin, -pi, pi,lty=1); c. plot(sin, -pi, pi) 3. Consider figure 3. Following R code plot(c(−3, 3), c(−3, 3), type = “n”), figure 3 is generated using a. points(c(1,-1),c(-1,-1)); b. points(c(-1,1),c(1,-1)) ; c. points(c(-1,-1),c(1,1)) 4. Consider figure 4. Following R code plot(c(−3, 3), c(−3, 3), type = “n”), figure 4 is generated using a. abline(0,1); b. abline(1,1) c. abline(0,0) 5. The cumulative distribution function (cdf) of a random variable X is defined as P (X ≤x) for −∞< x < ∞. a. Use plot() to draw the cdf of standard normal over the range of −3 to 3. >plot(P,-3,3) b. Use title() to add a title “standard normal cdf” to the plot in Part a. >title(main=”standard normal cdf”,font.main=5) c. Use abline() to add a blue vertical line at x = 2. >abline(v=2) d. Use points() to add a red point at x = 0, y = .5. Does the normal cdf curve go through this point? Why? >points(0,5,col=”red”) e. Define a function named “myfunction”. The input is x, and the output is sin(x)/2+.5. >myfunction=x(sin(x)/2+5)
f. Use plot(add = T RU E) to plot the function “myfunction” in the same figure as the previous plot. Plot the line in green, and use dashed line instead of solid line. >plot(myfunction,add=TRUE,col=”red”,lty=2) (Hint: use lty=2) g. Use legend() to add a legend for the three lines: the blue vertical line, the black cdf curve, and the green myfunction dashed line.black cdf curve, and the green myfunction dashed line. >legend(“topleft”,c(“abline”,”cdf”,”myfunction”),col=c(“blue”,”black”,”green”))
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help