758568a1-cf02-4881-ad3f-1462427c92d6

758568a1-cf02-4881-ad3f-1462427c92d6 - Department of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Department of Statistics STATS 390 Summer Semester 2009 Assignment 1 Due: 12 January 2009 Please answer all questions. You have only till next Monday to have this done so get on it TODAY! 1. [6 mark(s)] Make the following R functions and record R output in your word document (a) [2 mark(s)] A function that calculates the area of a triangle of base length b and height h . Call the function triarea(b,h) calculate triarea(b=2,h=4) and record the result with the above code (b) [2 mark(s)] A function that calculates the perimeter of a circle of radius r . Call it circleper(r) calculate circleper(r=20) and record the result with the above code (c) [2 mark(s)] A function that plots a quadratic equation with y the vertical axis and x the horizontal. Use the curve() command with x taking values between -10 and 10. Call it myquad(a,b,c) where the a, b, and c correspond to y = ax 2 + bx + c calculate myquad(a=1,b=-5,c=6) and record the result with the above code and plot 2. [6 mark(s)] We often need to make up random variables by simulation, some distributions have already been pre-packaged in R (like rnorm() ) and we will now use one or two of them. (a) [2 mark(s)] Make a function that produces n values from a N ( mean = 10 , sd = 5) distribution. Call it mynorm(n) where n is the number of samples from N ( mean = 10 , sd = 5) Calculate mynorm(n=10) and record the answer with the function code. (b) [2 mark(s)] Make a new function that plots a histogram of normal values where the mean and sd are variables with n. Call it STATS 390 Summer Semester 2009 Assignment 1 Page 1 of 3
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
mynormhist(n,mn,std) where n is the number of samples from N ( mean = mn, sd = std ) Submit mynormhist(n=200,mn=2,std=5)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

758568a1-cf02-4881-ad3f-1462427c92d6 - Department of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online