logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Susanne ParkerNursing
(5/5)

806 Answers

Hire Me
expert
Aashif AliStatistics
(5/5)

990 Answers

Hire Me
expert
William LongMathematics
(5/5)

854 Answers

Hire Me
expert
Quintin MiddletonResume writing
(4/5)

731 Answers

Hire Me
R Programming
(5/5)

Calculate the sum of the 5th element o v1 and the 7th element of v2. Write an R function that returns the real roots of the quadratic ax2 + bx + c.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Assignment

Question 1 [20 marks, 14×1+2+2+2]

(a) Use the R function seq to create the following sequences (i) v1=1,2,3,4,5,6,7,8,9,10

(ii) v2=3,6,9,12,15,18,21,24,27,30

(iii) v3=1,4,7,10

(iv) v4=1,2.5,4,5.5,7

(b) Use rep and seq to create the vectors

(i) 0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4

(ii) 1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4

(iii) 1,2,3,4,2,3,4,5,3,4,5,6,4,5,6,7,5,6,7,8

(c) Calculate the sum of the 5th element o v1 and the 7th element of v2.

(d) Using only v1, v2, v3, v4 create new vectors containing the following sequences

(i) v5=3,12,21,30

(ii) v6=4,8,12,16,20,24,28,32,36,40

(e) Type in the commands

m1 = matrix(v1, nrow = 2, ncol = 5, byrow = TRUE)

m2 = matrix(v1, nrow = 2, ncol = 5)

m3 = t(m1)

(i) What does m1 look like?

(ii) What happens if you increase or decrease the number of rows and columns of the matrix m1?

(iii) What do you get when you type m1 %*% m2

(iv) What do you get when you type m1 %*% m3

(f) Plot the following curves

(i) sin(x) for 0 < x < 12π 

(ii) f (x)=926 log(9/16 + x) + 581 log(3/16 − x) + 104 log(1/16 + x) for 0 < x < 3/16 

(g) Using the matrix(), seq() and rep() functions, or cbind() or rbind(), construct the following matrix 

1 2 3 4 

2 3 4 5 

3 4 5 6

4 5 6 7 

Question 2 [20 marks, 6+4+6+2+2]

(a) Write an R function that returns the real roots of the quadratic ax2 + bx + c. The function should take a, b and c as arguments and return appropriate messages if the values entered don’t specify a quadratic or if there are no real roots. Use the function to determine the roots of 2x2 - x { 3.

(b) The equation 0 = x7 + 10000x6 + 1.06x5 + 10600x4 + 0.0605x3 + 605x2 + 0.0005x + 5

has exactly one real root.

(i) Plot the function to try to get a sense of where the root might be?

(ii) Write an R function that applies Newton’s method to find the root. The function should have 2 arguments : the initial value x0 and the tolerance value. The function should return the estimated solution, the function value at the estimate and the number of iterations.

(iii) What happens when you set x0 = 0?

(iv) What happens when you set x0 = 1?

Question 3 [20 marks, 2+2+4+4+3+3]

(a) Simulate samples of size 10000 from the following distributions

(i) X ∼ Binomial(n = 10, p = 6)

(ii) W ∼ Normal(µ = 100, σ2 = 9)

(b) Use the samples you generated in (a) to estimate the following probabilities. Also calculate the probabilities from their cdf’s.

(i) P(X < 5) (ii) P(W> 106)

(c) Find x such tha

(i) P(X < x)=0.9 (ii) P(W < x)=0.95

(5/5)
Attachments:

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme