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
Edwin KairuStatistics
(/5)

899 Answers

Hire Me
expert
Andrea LiguoriLaw
(5/5)

636 Answers

Hire Me
expert
Ligia QuintanaMarketing
(5/5)

709 Answers

Hire Me
expert
Brady GonzalesEnglish
(5/5)

780 Answers

Hire Me
R Programming
(5/5)

Examine the following code snippets and correct them where needed according to what they are intended for

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

STATISTICAL COMPUTING

Instructions:

 All of your work must be typeset using Rmarkdown and submitted online through the course’s blackboard shell.

 Any work submitted late would be penalized as follows:

any work submitted before midnight of the due date would attract a penalty of up to 10%

any work submitted a day late would attract a penalty of up to 25%

any work submitted two days late would attract a penalty of up to 50%

otherwise you’ll be awarded a zero mark.

 You are encouraged to discuss the assignment with others but at the end you must submit your individual work.

 Any form cheating is not allowed and plagiarized work will be awarded a zero mark.

Q1. Examine the following code snippets and correct them where needed according to what they are intended for.

Please note that you can not a new code that does a similar task.

(a) Compute proportion estimate of obtaining a face of 1 or 2 in a fair die as 

follows pˆ = Ixi≤2/n, where

i=1

Ixi≤2 = 1 xi ≤ 2

       0 otherwise.

 set. seed (1)

die   =   sample ( c(1:6) ,   1000 ,   replace   =   TRUE ) success = rep (0 , 1000)

for( i   in   1:100)

{

if( die   >   2){ success[ i]   ==   1}

}

hat. p   =   MEAN ( success)

(b)

Q2. The Gini index is defined by the following equation. 

2 Σn 

ixi 

n + 1

(a) Write down a user-defined function (call it gini.fn) that will calculate a value of this index for any given vector.

(b) Evaluate the Gini index for the number of hours spent watching television per week for a sample of 34 households.

23.1 15.9 21.0 26.0 25.1 14.7  24.2  16.6  18.2  16.5  20.7  15.3  17.7

19.1 22.7 21.9 14.6 26.3 25.8 9.4 17.0 21.2 17.9 24.7 21.1 17.2

19.1 22.7 24.0 24.7 22.5 8.3 2.5 30.4

Q3. A Newton method is one of the most popular numerical techniques used to finding roots of an algebraic function. That is, solving for f (x) = 0. According to the Newton method, if f (x) has a first derivative fJ(x) then the following algorithm will converge to a root of the above equation if the starting point is close enough.

Algorithm

a. Picking a starting value x0

b. For each estimate xn, calculate a new estimate

c.  Repeat step (b) until the estimate are very close togetheror until the method fails

Use R and the Newton method to approximate the root of

HINT: A while loop is the most appropriate for this problem. But first use curve to visualize this graph and see where the root are.

. The Taylor series for sin−1(x) for |x| ≤ 1 is given by

(a) Write a function in R that will approximate sin−1(x) to some allowable toler- ance error. The arguments of your function should be x and tol (tolerance error), and return the approximate value of sin−1(x) and the total number of terms (N) summed together to give an approximate within the pre-stated tolerance error.

(b) Use your function to approximate sin−1(π/4) within a tolerance error of 0.001. Compare your solution with the R computed value.

(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